def register_extensions(app): bcrypt.init_app(app) db.init_app(app) csrf_protect.init_app(app) login.init_app(app) debug_toolbar.init_app(app) mail.init_app(app) migrate.init_app(app, db) moment.init_app(app) if not app.debug and not app.testing: if app.config['MAIL_SERVER']: auth = None if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']: auth = (app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD']) secure = None if app.config['MAIL_USE_TLS']: secure = () mail_handler = SMTPHandler( mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), fromaddr='no-reply@' + app.config['MAIL_SERVER'], toaddrs=app.config['ADMINS'], subject='Microblog Failure', credentials=auth, secure=secure) mail_handler.setLevel(logging.ERROR) app.logger.addHandler(mail_handler) return None
def register_extensions(app): origins = app.config.get('CORS_ORIGIN_WHITELIST', '*') cors.init_app(app, origins=origins) db.init_app(app) migrate.init_app(app, db) mail.init_app(app) jwt.init_app(app)
def register_extensions(app): """第三方插件集装箱""" cache.init_app(app) # mongo.init_app(app) #将mongodb注册到app中 celery.init_app(app) cors.init_app(app, supports_credentials=True) # 配置全局跨域路由 mail.init_app(app)
def create_app(config=None): app = JSONFlask(__name__) if config: app.config.from_object(config) db.init_app(app) jwt.init_app(app) cors.init_app(app) mail.init_app(app) app.register_blueprint(account_bp, url_prefix='/api/v1/account') app.register_blueprint(categories_bp, url_prefix='/api/v1/categories') app.register_blueprint(food_item_state_bp, url_prefix='/api/v1/food_item_state') app.register_blueprint(stock_bp, url_prefix='/api/v1/stock') app.register_blueprint(snapshot_bp, url_prefix='/api/v1/snapshot') app.register_blueprint(unit_of_measure_bp, url_prefix='/api/v1/unit_of_measure') @app.route('/', defaults={'path': ''}) @app.route('/<path:path>') def catch_all(path): return app.send_static_file("index.html") return app
def load(env): # Flag parsing with wsgi runners is a major pain # We identify a flag break '--' and consume only flags after it if env != 'dev': if '--' in sys.argv: separator = sys.argv.index('--') args = sys.argv[separator:] logging.debug( 'Prod mode, loading args the hard way: {args}'.format( args=args)) else: args = sys.argv FLAGS(args) else: FLAGS(sys.argv) # Init sentry as early as possible to catch as much as possible if FLAGS.sentry: sentry_sdk.init(dsn=FLAGS.sentry, integrations=[FlaskIntegration()], environment=env, release=__version__) app = Flask(__name__) app.config.from_object('websiteconfig') # gRPC channel init global channels kwargs = {} if FLAGS.consul: kwargs['consul'] = True if FLAGS.jaeger: tracer = init_tracer() kwargs['tracer'] = tracer flask_tracer = FlaskTracing(tracer, True, app) logging.info('Flask tracing enabled') channels = Channels(**kwargs) channels.refresh_all() lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) flask_static_digest.init_app(app) from app import user, maintenance, asset, pwa app.register_blueprint(user.bp) app.register_blueprint(maintenance.bp) app.register_blueprint(asset.bp) app.register_blueprint(pwa.bp) @app.route('/') def root(): return render_template('index.html') @app.route('/favicon.ico') def favicon(): return send_from_directory('static', 'img/icons/favicon.ico') return app
def configure_extensions(app): from app.extensions import db, login, migrate, mail, moment db.init_app(app) login.init_app(app) login.login_view = 'static_views.login' migrate.init_app(app, db) mail.init_app(app) moment.init_app(app)
def register_extensions(app): db.init_app(app) login_manager.init_app(app) migrate.init_app(app, db) mail.init_app(app) csrf.init_app(app) return None
def register_extensions(app): db.init_app(app) lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) celery.config_from_object(app.config) assets.init_app(app) babel.init_app(app)
def register_plugin(app): db.init_app(app) bootstrap.init_app(app) moment.init_app(app) mail.init_app(app) ckeditor.init_app(app) login_manager.init_app(app) csrf.init_app(app)
def register_extensions(app): from app.extensions import db from app.extensions import mail from app.extensions import migrate db.init_app(app) mail.init_app(app) migrate.init_app(app, db)
def register_extensions(app): """Register extension with app.""" db.init_app(app) migrate.init_app(app, db) login.init_app(app) csrf.init_app(app) mail.init_app(app) sess.init_app(app)
def register_extensions(app): bootstrap.init_app(app) moment.init_app(app) db.init_app(app) mail.init_app(app) login_manager.init_app(app) toolbar.init_app(app) cache.init_app(app) ckeditor.init_app(app)
def configure_extensions(app): db.init_app(app) login_manager.init_app(app) flask_whooshalchemyplus.init_app(app) DebugToolbarExtension(app) cache.init_app(app) bootstrap.init_app(app) md.init_app(app) mail.init_app(app)
def extensions(app): db.init_app(app) debug_toolbar.init_app(app) db_migrate.init_app(app,db) login.init_app(app) crsf.init_app(app) mail.init_app(app) api.init_app(app)
def register_extensions(app): bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) page_down.init_app(app) debug_toolbar.init_app(app) migrate.init_app(app, db)
def register_extensions(app): heroku.init_app(app) travis.init_app(app) db.init_app(app) api.init_app(app) lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) celery.config_from_object(app.config) assets.init_app(app)
def configure_extensions(app): # configure extensions bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.session_protection = 'strong' login_manager.login_view = 'auth.login' login_manager.login_message = u"Please log in to access this page. " login_manager.init_app(app)
def configure_extensions(app): """Configures the extensions.""" # Enable CORS cors.init_app(app) # Init Flask-SQLAlchemy db.init_app(app) # Init Flask-Migrate migrate.init_app(app, db) # Init Flask-Mail mail.init_app(app)
def register_extensions(app): bootstrap.init_app(app) db.init_app(app) login.init_app(app) csrf.init_app(app) ckeditor.init_app(app) mail.init_app(app) moment.init_app(app) toolbar.init_app(app) migrate.init_app(app, db)
def register_extentions(app): bootstrap.init_app(app) db.init_app(app) moment.init_app(app) mail.init_app(app) login_manager.init_app(app) dropzone.init_app(app) csrf.init_app(app) avatars.init_app(app) whooshee.init_app(app)
def register_extensions(server): from app.extensions import db from app.extensions import login_inst from app.extensions import migrate from app.extensions import mail db.init_app(server) login_inst.init_app(server) login_inst.login_view = 'main.login' migrate.init_app(server, db) mail.init_app(server)
def config_extensions(app): bootstrap.init_app(app) db.init_app(app) mail.init_app(app) moment.init_app(app) login_manage.init_app(app) login_manage.session_protection = 'strong' login_manage.login_view = 'user.login' login_manage.login_message = '请先登录' configure_uploads(app, photos) patch_request_class(app, size=None)
def register_extensions(app): """Register extensions with the Flask application.""" travis.init_app(app) db.init_app(app) lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) assets.init_app(app) babel.init_app(app) rq.init_app(app) migrate.init_app(app, db)
def register_extensions(app): heroku.init_app(app) travis.init_app(app) db.init_app(app) api.init_app(app) lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) celery.config_from_object(app.config) assets.init_app(app) babel.init_app(app) csrf.init_app(app)
def extensions(app): """ Register extenstions on the application instance :param app: Flask Application instance :return: None """ mail.init_app(app) db.init_app(app) csrf.init_app(app) login_manager.init_app(app)
def register_extensions(app): babel.init_app(app) bcrypt.init_app(app) bootstrap.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) mail.init_app(app) moment.init_app(app)
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) mail.init_app(app) return None
def config_extensions(app): db.init_app(app) bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) login_manger.init_app(app) # 默认'basic',另外None禁用,'strong'用户信息改的立即退出登录 login_manger.session_protection = 'strong' # 设置登录页面的端点(视图函数),访问选用登录才有权限的URL时自动跳转 login_manger.login_view = 'user.login' # 需要登录时的提示信息,默认是英文字符串 login_manger.login_message = '需要登录才可访问'
def register_extensions(app): """Register extensions with the Flask application.""" travis.init_app(app) db.init_app(app) lm.init_app(app) mail.init_app(app) bcrypt.init_app(app) assets.init_app(app) babel.init_app(app) rq.init_app(app) migrate.init_app(app, db) limiter.init_app(app)
def create_app(config=Config): app = Flask(__name__) app.config.from_object(config) app.secret_key = os.urandom(24) app.register_blueprint(main) Menu(app=app) db.init_app(app) login_manager.init_app(app) login_manager.login_view = "main.login" login_manager.login_message_category = "warning" mail.init_app(app) return app
def register_extensions(app): debug_toolbar.init_app(app) db.init_app(app) migrate.init_app(app, db) login_manager.init_app(app) bootstrap.init_app(app) moment.init_app(app) mail.init_app(app) api.init_app(app) jwt.init_app(app) limiter.init_app(app)
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)
def create_app(config_name='dev'): app = Flask(__name__) # sifn = show if none app.jinja_env.filters['sifn'] = lambda it: '无' if not it else it app.jinja_env.filters['with_site'] = lambda title: title + ' - pkyx' # 导入配置 app.config.from_object(config[config_name]) config[config_name].init_app(app) # 初始化flask_admin admin.init_app(app) admin.add_view(FileView(os.path.join(os.path.dirname(__file__), 'static'), '/static/')) # 初始化MongoDB mongo.init_app(app) with app.app_context(): mongo.db['items'].create_index('title', background=True) # 初始化Celery celery.init_app(app) # 初始化Flask-mail mail.init_app(app) # 初始化Flask-Login login_manager.init_app(app) login_manager.login_view = 'main.register' login_manager.login_message = '请先登录或注册' @login_manager.user_loader def load_user(user_id): user = None db_user = mongo.db.users.find_one({"_id": bson_obj_id(user_id)}) if db_user is not None: user_id = db_user.pop('_id') user = User(user_id, extras=db_user) return user # @login_manager.unauthorized_handler # def unauthorized(): # pass from app.main import main as main_blueprint app.register_blueprint(main_blueprint) from app.users import users as users_blueprint app.register_blueprint(users_blueprint) from app.api import api as api_blueprint app.register_blueprint(api_blueprint) return app
def configure_extensions(app): mail.init_app(app) cache.init_app(app) mdb.init_app(app)
def configure_extensions(app): db.init_app(app) mail.init_app(app)