def create_app(config, env="prod"): """ Application factory config - the config object env - name of environment to load """ app = Flask(__name__) app.config.from_object(config) app.config['ENV'] = env # Flask cache init cache.init_app(app) # Markdown md = Markdown(app) # initialize the debug tool bar debug_toolbar.init_app(app) # initialize SQLAlchemy db.init_app(app) login_manager.init_app(app) # register our blueprints app.register_blueprint(main) app.register_blueprint(user, url_prefix='/user') app.register_blueprint(api, url_prefix='/api') return app
def register_extensions(app): db.init_app(app) bootstrap.init_app(app) moment.init_app(app) login_manager.init_app(app) ckeditor.init_app(app) csrf.init_app(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 create_app(app_config): """Initialize the core application.""" app = Flask(__name__, instance_relative_config=False) app.config.from_object(app_config) # Initialize plugins compress.init_app(app) login_manager.init_app(app) db.init_app(app) with app.app_context(): from blog.views import app_blueprint, error400, error404, error500 # Register blueprints app.register_blueprint(app_blueprint) # Register error pages app.register_error_handler(400, error400) app.register_error_handler(404, error404) app.register_error_handler(500, error500) # Create database tables for our data models db.create_all() return app
def register_extensions(app): bootstrap.init_app(app) # 扩展的实例化和初始化 db.init_app(app) migrate.init_app(app, db) moment.init_app(app) ckeditor.init_app(app) mail.init_app(app) login_manager.init_app(app) csrf.init_app(app)
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 register_extensions(app): bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) mail.init_app(app) dropzone.init_app(app) moment.init_app(app) whooshee.init_app(app) avatars.init_app(app) csrf.init_app(app) ckeditor.init_app(app)