def create_app(): app = Flask(__name__) app.config.from_pyfile("config/default.py") app.config.from_envvar('APP_CONFIG_FILE') #app.config.from_pyfile("config/development.py") # app.config.from_object(settings_module) # Inicializa las extensiones db.init_app(app) marshmallow.init_app(app) migrate.init_app(app, db) # Captura todos los errores 404 Api(app, catch_all_404s=True) # Deshabilita el modo estricto de acabado de una URL con / app.url_map.strict_slashes = False #Api Blueprints app.register_blueprint(measurement_blueprint) app.register_blueprint(magnitude_blueprint) app.register_blueprint(station_blueprint) app.register_blueprint(density_blueprint) app.register_blueprint(holiday_blueprint) app.register_blueprint(event_blueprint) app.register_blueprint(report_blueprint) app.register_blueprint(timeline_blueprint) app.register_blueprint(town_blueprint) return app
def create_app(): """ 初始化app :return: app """ app = Flask(__name__) app.config.from_object(Config) csrf.init_app(app=app) celery.init_app(app=app) app.register_blueprint(spider_management_bp) app.register_blueprint(api_bp) from app.views.Task import Tasks_bp app.register_blueprint(Tasks_bp) csrf.exempt(spider_management_bp) csrf.exempt(api_bp) db.init_app(app) with app.test_request_context(): db.create_all() redis_client.init_app(app) print(app.url_map) return app
def extension_register(app): login_manager.init_app(app) login_manager.login_view = 'web.login' login_manager.login_message = 'Your custom message' login_manager.login_message_category = 'warning' bootstrap.init_app(app) db.init_app(app) admin_register(app)
def registerExtensions(app: Flask): ''' 配置插件 :param app: :return: ''' bcrypt.init_app(app) cors.init_app(app) # schedule.init_app(app) # schedule.start() db.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) return None
def create_app(config_name=None): '''传入配置名: 'development' 'testing' 'production' 'default'(development模式) 如若为None则为default ''' config_name = config_name or 'default' app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) toolbar.init_app(app) db.init_app(app) pagedown.init_app(app) login_manager.init_app(app) mail.init_app(app) configure_uploads(app, photos) create_slow_query_handler(app) from . import admin_view if admin.app is None: admin.init_app(app) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') from .api_post import api_post as api_post_blueprint app.register_blueprint(api_post_blueprint, url_prefix='/api/post') return app
def register_db(app): db.init_app(app)
def register_extensions(app): db.init_app(app) mail.init_app(app)
from flask import Flask from app.views.user import user_page from app.views.product import product_page from app.views.update import itself_page from app.extension import db import os app = Flask('app') app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:mysql@localhost/app' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.secret_key = "lalskskskskksksjsj" db.init_app(app) app.register_blueprint(user_page) app.register_blueprint(product_page) app.register_blueprint(itself_page)
def register_extensions(app): migrate.init_app(app, db) db.init_app(app) cors.init_app(app)