Beispiel #1
0
    db.app = app
    db.init_app(app)
    # add whitenoise
    return app


app = create_app(__name__)
# admin = Admin(app, name='tflsgo', template_mode='bootstrap3')
# admin.add_view(ModelView(User, db.session))
# admin.add_view(ModelView(Algorithm, db.session))
Compress(app)
api = Api(app)
# Check Configuring Flask-Cache section for more details
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
cache.clear()
gen_static()


class Benchmark(Resource):
    """
    Rest object to receive the benchmark information.
    """
    @cache.cached(timeout=300)
    def get(self):
        """
        Return the information about benchmarks.
        """
        return {'benchmarks': get_benchmarks()}

Beispiel #2
0
            return jsonify({"status": "fail", "id": id, "msg": "更新的图片不存在!"})
    elif request.method == 'PATCH':
        # 全部属性更新
        id = request.form.get('id')
        img = Image.query.get(int(id))
        img.name = request.form.get('name')
        img.url = request.form.get('url')

        session.add(img)  # 保存或更新

        result['msg'] = '图片的名称和路径更新成功!'

    elif request.method == 'DELETE':
        id = request.args.get('id')
        img = Image.query.get(int(id))

        session.delete(img)

        result['id'] = id
        result['msg'] = '删除图片成功!'

    if request.method != 'GET':
        session.commit()

    return jsonify(result)


if __name__ == '__main__':
    cache.clear()  # 清除缓存
    app.run(debug=True, port=8000)
Beispiel #3
0
from slot import app

# Set up logging
log = logging.getLogger('slot')
log.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
log.addHandler(ch)

app.config.from_object('config')
sslify = SSLify(app, age=300)
cache = Cache(app, config={'CACHE_TYPE': 'redis'})

with app.app_context():
    cache.clear()

from slot.users.views import users_blueprint
from routes import dashboard, render_new_procedure_form, receive_sms, complete_procedure
import slot.users.controller as user_controller
import db_fieldbook as db
import error_mailer

error_mailer.initialize_app(app, additional_loggers=['slot'])

# Register blueprints
app.register_blueprint(users_blueprint)

# Initialise flask_login
login_manager = LoginManager()
login_manager.init_app(app)