Exemple #1
0
def createShelter():
    she = Shelter.insert().values(name='Второй',
                                  description='Описание второго')
    db_session.execute(she)
    db_session.commit()
    query = Shelter.select()
    shelters = db_session.execute(query)
    result = [dict(shelter) for shelter in shelters]
    return jsonify(result)
Exemple #2
0
def file_record(file_uuid):
    try:
        query = Files.select().where(Files.c.file_uuid == file_uuid)
        file_record = db_session.execute(query).first()
    except Exception:
        return abort(404)
    return jsonify(dict(file_record))
Exemple #3
0
def file_upload():
    file = request.files['file']
    mime = file.mimetype
    fs = FilesService()
    new_filename = fs.upload(file)
    file_record = Files.insert().values(
        dist='http://localhost:5001/' + new_filename.replace('\\', '/'),
        mimetype=mime).returning(literal_column('*'))
    result = db_session.execute(file_record)
    db_session.commit()
    return jsonify(dict(result.first()))
Exemple #4
0
def shelters():
    query = Shelter.select()
    shelters = db_session.execute(query)
    result = [dict(shelter) for shelter in shelters]
    return jsonify(result)
Exemple #5
0
def shelter(shelter_uuid):
    query = Shelter.select().where(Shelter.c.shelter_uuid == shelter_uuid)
    shelter = db_session.execute(query).first()
    return jsonify(dict(shelter))