def register_extensions(app): from server.extensions import ( db, migrate, mail, babel, cors, jwt, cache, compress, swagger, ) db.init_app(app) migrate.init_app(app, db) mail.init_app(app) babel.init_app(app) cors.init_app( app, resources={r"/api/*": {"origins": "*"}}, supports_credentials=True ) jwt.init_app(app) cache.init_app(app) compress.init_app(app) swagger.init_app(app) # Return validation errors as JSON @app.errorhandler(422) @app.errorhandler(400) def handle_error(err): messages = err.data.get("messages", "Invalid request.") return jsonify({"message": messages["json"]}), 400
def create_app(script_info=None, settings_name='server.config.DevelopmentConfig'): app = Flask(__name__, template_folder='../client/templates', static_folder='../client/static') app_settings = os.getenv('APP_SETTINGS', settings_name) app.config.from_object(app_settings) bcrypt.init_app(app) db.init_app(app) migrate.init_app(app, db) mail.init_app(app) jwt.init_app(app) register_errors(app) app.config.update({'OAUTH1_PROVIDER_ENFORCE_SSL': False}) app.shell_context_processor({'app': app, 'db': db}) api = init_api(app) api_urls(api) app.register_blueprint(google_blueprint) initialize_black_list_loader() return app
def register_extensions(app): """Register Flask extensions.""" api.init_app(app) bcrypt.init_app(app) db.init_app(app) mail.init_app(app) migrate.init_app(app, db) return None
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)
def get_celery_app_with_db(): flask_app = Flask(__name__, template_folder='../../client/templates', static_folder='../../client/static') app_settings = os.getenv('APP_SETTINGS', 'server.config.CeleryConfig') flask_app.config.from_object(app_settings) celery = make_celery(flask_app) db.init_app(flask_app) mail.init_app(flask_app) return celery
def extensions(app): """ Register extensions. :param app: Flask application instance :return: None """ debug_toolbar.init_app(app) mail.init_app(app) csrf.init_app(app) db.init_app(app) login_manager.init_app(app) limiter.init_app(app) jwt.init_app(app) return None
def create_app(config='develop'): """App factory.""" app = Flask( __name__, static_folder='../static', static_url_path='/static-native', ) config = configs[config] app.config.from_object(config) db.init_app(app) ma.init_app(app) migrate.init_app(app, db) mail.init_app(app) passlib.init_app(app) from server.handlers import register_handlers register_handlers(app) register_blueprints(app) data.module_data = load_modules(getattr(config(), "MODULE_FILE_PATH")) data.research_data = load_research(getattr(config(), "RESEARCH_FILE_PATH")) return app
def register_extensions(): if not BaseConfig.DEBUG: SSLify(app) mail.init_app(app)