def create_app(config_class=Config): app = Flask(__name__) app.config.from_object(config_class) bootstrap.init_app(app) db.init_app(app) login.init_app(app) moment.init_app(app) admin.init_app(app) from app.main import bp as main_bp app.register_blueprint(main_bp) from app.auth import bp as auth_bp app.register_blueprint(auth_bp) from app.error import bp as error_bp app.register_blueprint(error_bp) from app.article import bp as article_bp app.register_blueprint(article_bp) from app.post import bp as post_bp app.register_blueprint(post_bp) return app
def configure_extensions(app): ''' 配置扩展 ''' db.init_app(app) migrate.init_app(app, db) # cors.init_app(app) bootstrap.init_app(app) login.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)
def register_extensions(app): csrf_protect.init_app(app) login_manager.init_app(app) bootstrap.init_app(app) db.init_app(app) migrate.init_app(app, db) return None
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 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 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 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 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 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) avatars.init_app(app) whooshee.init_app(app)
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(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 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(server): from app.extensions import db from app.extensions import login from app.extensions import migrate from app.extensions import bootstrap db.init_app(server) login.init_app(server) login.login_view = 'main.login' migrate.init_app(server, db) bootstrap.init_app(server)
def register_extensions(app): """ 第三方扩展 :param app: :return: """ bootstrap.init_app(app) db.init_app(app) migrate.init_app(app, db) login_manager.init_app(app) csrf.init_app(app)
def register_extensions(app): db.init_app(app) bootstrap.init_app(app) ckeditor.init_app(app) login_manager.init_app(app) csrf.init_app(app) pagedown.init_app(app) moment.init_app(app) migrate.init_app(app, db) sitemap.init_app(app) search.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): 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 extensions(app): # initializes all currently used extensions in the application. bootstrap.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) mail.init_app(app) pagedown.init_app(app) #celery.conf.update(app.config) #debug_toolbar.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 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) bootstrap.init_app(app) moment.init_app(app) return None
def create_app(): app = Flask(__name__) app.secret_key = "000" bootstrap.init_app(app) database.init_app(app) index.init_app(app) users.init_app(app) adm.init_app(app) return app
def create_app(): ''' Initialise the application with necessary extensions ''' app = Flask(__name__) app.config.from_object(Config) app.app_context().push() bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) app.register_blueprint(main) app.register_blueprint(auth) app.register_blueprint(jinja_templates) app.register_blueprint(errors) github_blueprint = make_github_blueprint( client_id=Config.client_id, client_secret=Config.client_secret) github_blueprint.backend = SQLAlchemyBackend(OAuth, db.session, user=current_user, user_required=False) app.register_blueprint(github_blueprint, url_prefix='/login') @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id)) @oauth_authorized.connect_via(github_blueprint) def github_logged_in(blueprint, token): account_info = blueprint.session.get('/user') if account_info.ok: account_info_json = account_info.json() username = account_info_json['login'] query = User.query.filter_by(username=username) try: user = query.one() except NoResultFound: user = User(username=username) db.session.add(user) db.session.commit() login_user(user) flash("Successfully signed in with GitHub.", 'success') return app
def register_extensions(app): """Register the application instance with the extensions.""" bootstrap.init_app(app) db.init_app(app) mail.init_app(app) login_manager.init_app(app) configure_uploads(app, images) patch_request_class(app) # redirect requests sent to http to secure https when deployed on Heroku if app.config["SSL_REDIRECT"]: from flask_sslify import SSLify sslify = SSLify(app)
def extensions(app): """ Register 0 or more flask extensions (mutates the app passed in). :param app: Flask application instance :return: None """ bootstrap.init_app(app) csrf.init_app(app) db.init_app(app) migrate.init_app(app, db) login_manager.init_app(app) return None
def create_app(config_name): app = Flask(__name__) #app是Flask的实例,接收包或者模块的名字作为参数,但一般都是传递__name__ app.config.from_pyfile('../Config/setting.py') # 推荐object对象方式 register_blue(app) login_manager.init_app(app) #在extension实例化类 在ini_app方法初始化 db.init_app(app) bootstrap.init_app(app) app.config['HOST'] print(app.config['HOST']) logger = get_logger() logger.debug("msg") return app
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)
def app_create(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) db.init_app(app) bootstrap.init_app(app) mongo.init_app(app) # 注册蓝本,在此添加 from .main import main as main_blueprint app.register_blueprint(main_blueprint) # 路由和其他处理程序定义 # ... return 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) # toolbar.init_app(app) # task services # csrf.init_app(app) scheduler.init_app(app) db.init_app(app)
def extensions(app): """ Register 0 or more extensions (mutates the app passed in). :param app: Flask application instance :return: None """ mail.init_app(app) csrf.init_app(app) db.init_app(app) login_manager.init_app(app) bootstrap.init_app(app) # initialize bootstrap bcrypt.init_app(app) return None
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) # Register our blueprints from .cast import cast as cast_blueprint from .auth import auth as auth_blueprint from .api_1_0 import api as api_blueprint from .api_1_1 import api_1_1 as api_blueprint_1_1 from .admin import admin as admin_blueprint from .dj import dj as dj_blueprint app.register_blueprint(cast_blueprint) app.register_blueprint(auth_blueprint, url_prefix="/auth") app.register_blueprint(api_blueprint, url_prefix="/api") app.register_blueprint(api_blueprint_1_1, url_prefix="/api1.1") app.register_blueprint(admin_blueprint, url_prefix="/admin") app.register_blueprint(dj_blueprint, url_prefix="/dj") # Initialize any extensions we are using bootstrap.init_app(app) login_manager.init_app(app) moment.init_app(app) def nl2br(value): return value.replace("\n", "<br>\n") app.jinja_env.filters["nl2br"] = nl2br @app.route("/robots.txt") def robots_from_static(): return send_from_directory(os.path.join(app.root_path, "static"), "robots.txt") @app.before_request def before_request(): g.next_cast = Cast.query.order_by(Cast.cast_number.desc()).first() msgs = Announcement.query.all() if msgs: for msg in msgs: flash("%s" % msg.message, "%sannouncement" % msg.id) whooshalchemy.whoosh_index(app, Pick) return app
def register_extensions(app): db.init_app(app) celery.init_app(app) bootstrap.init_app(app) moment.init_app(app)