def create_app(config=None): # create app app = Flask(__name__) # set config if config == 'testing': app.config.from_object(configure.TestingConfig) elif config == 'development': app.config.from_object(configure.DevelopmentConfig) elif config == 'production': app.config.from_object(configure.ProductionConfig) else: raise ValueError('Incorrect configuration') # extensions db.init_app(app) migrate.init_app(app, db) cache.init_app(app) # blueprints from .routes import blueprint as blog app.register_blueprint(blog, url_prefix='') return app
def register_extensions(app): db.init_app(app) migrate.init_app(app, db, compare_type=True) csrf.init_app(app) admin.init_app(app) api.plugins = [ EventPlugin(), PermissionPlugin(), ApiSpecPlugin(app=app, tags={ 'Tag': 'Tag API', 'User': '******', 'Author': 'Author API', 'Article': 'Article API', }), ] api.init_app(app) login_manager.login_view = 'auth.login' login_manager.init_app(app) @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id))
def register_extensions(app): """Register Flask extensions.""" bcrypt.init_app(app) cache.init_app(app) db.init_app(app) migrate.init_app(app, db) jwt.init_app(app)
def register_extensions(app): bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) csrf.init_app(app) ckeditor.init_app(app) moment.init_app(app) migrate.init_app(app, db)
def register_extensions(app): bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) # mail.init_app(app) moment.init_app(app) # whooshee.init_app(app) csrf.init_app(app) migrate.init_app(app, db)
def configure_extensions(app): db.init_app(app) migrate.init_app(app, db) lm.init_app(app) bootstrap.init_app(app) ckeditor.init_app(app) configure_uploads(app, icon) register_error_handlers(app) sentry_sdk.init(dsn=SENTRY_DSN, integrations=[FlaskIntegration()]) @lm.user_loader def load_user(user_id): return User.query.get(int(user_id))