예제 #1
0
def register_extensions(app):
    """Register Flask extensions."""
    cors.init_app(app)
    webpack.init_app(app)
    socketio.init_app(app, message_queue='redis://')
    db.init_app(app)
    if not get_debug_flag():
        scheduler.init_app(app)
        scheduler.start()
        scheduler.run_job('missingcheck')
예제 #2
0
def _register_extensions(app):
    """
    注册组件
    Args:
        app:

    Returns:

    """
    socketio.init_app(app)
예제 #3
0
def create_app():
    app = Flask('SingleAccountLogin')
    app.config.from_object(Config)

    db.init_app(app)
    socketio.init_app(app)
    login_manager.init_app(app)

    app.register_blueprint(demo_bp)

    return app
예제 #4
0
def register_extensions(app):
    from app.extensions import db
    from app.extensions import migrate
    from app.extensions import assets
    from app.extensions import socketio
    from app.extensions import login

    db.init_app(app)
    migrate.init_app(app, db)
    assets.init_app(app)
    socketio.init_app(app)
    login.init_app(app)
예제 #5
0
def register_extensions(app):
    """Register Flask extensions."""
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    flask_static_digest.init_app(app)
    socketio.init_app(app)
    return None
예제 #6
0
def register_extensions(app: Flask):
    """Register Flask-Plugin modules"""
    assets.init_app(app)
    db.init_app(app)
    cache.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)
    marshmallow.init_app(app)
    login.init_app(app)
    login.blueprint_login_views = {'auth': '/login'}
    from app.blueprints.term import events  # necessary for socketio
    socketio.init_app(app, async_mode=None)
예제 #7
0
def run_as_socketio(app, args):
    """在socketio中运行"""
    from app.extensions import socketio

    socketio.init_app(app)

    socketio.run(
        app,
        host=args.bind,
        debug=args.debug,
        use_reloader=args.use_reloader,
        port=args.port,
    )
예제 #8
0
파일: app.py 프로젝트: 1111mp/flask_init
def register_extensions(app):
    """给Flask注册扩展功能"""
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    xtredis.init_app(app)
    # csrf_protect.init_app(app)
    login_manager.init_app(app)
    cors.init_app(app, resources=r'/*', supports_credentials=True)
    migrate.init_app(app, db)
    flask_static_digest.init_app(app)
    socketio.init_app(app, cors_allowed_origins='*',
                      logger=True, engineio_logger=True)
    return None
예제 #9
0
def register_extensions(app):
    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    login_manager.login_view = 'web.login'
    login_manager.login_message_category = 'warning'
    avatars.init_app(app)
    pagedown.init_app(app)
    #cache.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    csrf.init_app(app)
    socketio.init_app(app)
    oauth.init_app(app)
예제 #10
0
def register_extensions(app, content, config_object):
    """
    Init extension
    :param app:
    :param content:
    :return:
    """
    client.app = app
    client.init_app(app)
    socketio.init_app(app)
    # don't start extensions if content != app
    if content == 'app':
        jwt.init_app(app)
    # logger
    logger = logging.getLogger('api')
    logger.setLevel(logging.ERROR)
    logger.addHandler(app_log_handler)

    @app.after_request
    def after_request(response):
        # This IF avoids the duplication of registry in the log,
        # since that 500 is already logged via @app.errorhandler.
        if response.status_code != 500:
            ts = strftime('[%Y-%b-%d %H:%M]')
            logger.error('%s %s %s %s %s %s', ts, request.remote_addr,
                         request.method, request.scheme, request.full_path,
                         response.status)
        return response

    @app.errorhandler(Exception)
    def exceptions(e):
        ts = strftime('[%Y-%b-%d %H:%M]')
        tb = traceback.format_exc()
        error = '{} {} {} {} {} 5xx INTERNAL SERVER ERROR\n{}'.format \
                (
                ts,
                request.remote_addr,
                request.method,
                request.scheme,
                request.full_path,
                tb
            )

        logger.error(error)

        return "Internal Server Error", 500
예제 #11
0
def register_extensions(app):
    """Register the Flask app with various extensions."""
    bcrypt.init_app(app)
    ma.init_app(app)
    socketio.init_app(app)
예제 #12
0
def _register_extension(app):
    db.init_app(app)
    moment.init_app(app)
    csrf.init_app(app)
    socketio.init_app(app)
예제 #13
0
def register_extensions(app):
    db_sql.init_app(app)
    socketio.init_app(app)