Exemplo n.º 1
0
def extension(app):
    print('hi there')
    csrf.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    moment.init_app(app)
    return None
Exemplo n.º 2
0
def create_app():
    app = Flask(__name__)

    config = os.environ.get('APP_SETTINGS', 'project.config.ProductionConfig')
    app.config.from_object(config)

    for bp in all_blueprints:
        import_module(bp.import_name)
        app.register_blueprint(bp)

    login_manager.login_view = "index.register"

    logging.config.dictConfig(app.config["LOG_CONFIG"])

    if app.config.get('TESTING'):
        werkzeug_logger = logging.getLogger('werkzeug')
        werkzeug_logger.setLevel(logging.ERROR)

    csrf.init_app(app)
    toolbar.init_app(app)
    db.init_app(app)
    # FIXME: OMG Flask-SQLAlchemy doesn't set app instance when init_app()
    db.app = app
    login_manager.init_app(app)
    login_manager.user_loader(load_user)
    redis_store.init_app(app)
    oauth.init_app(app)
    cache.init_app(app, config={'CACHE_TYPE': 'redis'})

    return app
Exemplo n.º 3
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)
    # webpack.init_app(app)
    return None
Exemplo n.º 4
0
def configure_extensions(app: Flask):
    """ Configure flask app extensions. """
    from project.extensions import login_manager
    from project.extensions import csrf
    from project.extensions import oauth
    from project.services.account import (
        AccountService,
        AnonymousAccount,
        ANONYMOUS_ACCOUNT,
    )

    login_manager.init_app(app)
    csrf.init_app(app)

    login_manager.user_loader(AccountService.get_by_id)
    login_manager.anonymous_user = AnonymousAccount
    login_manager.login_view = "static.login"

    # remove db and user_settings when needed
    @app.teardown_appcontext
    def teardown_db(_):
        g.pop("user_settings", None)
        g_db = g.pop("db", None)
        if g_db is not None:
            g_db.close()

    oauth.init_app(app)

    if app.config["AUTH_OPENID_ENABLED"]:
        # register the oauth client
        oauth.register(
            name="auth",
            client_id=app.config["AUTH_CLIENT_ID"],
            client_secret=app.config["AUTH_CLIENT_SECRET"],
            server_metadata_url=app.config["AUTH_SERVER_METADATA_URL"],
            client_kwargs={"scope": "openid profile"},
        )
def configure_extensions(app):
    db.init_app(app)
    login_manager.init_app(app)
    bootstrap.init_app(app)
Exemplo n.º 6
0
def extent(app):
    oauth.init_app(app)
    csrf.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    return None