예제 #1
0
    def setup_db(self) -> None:
        db.init_app(self.flask_app)

        with self.flask_app.app_context():  # type: ignore
            pessimistic_connection_handling(db.engine)

        migrate.init_app(self.flask_app, db=db, directory=APP_DIR + "/migrations")
예제 #2
0
    except Exception as e:
        print("blueprint registration failed")
        logging.exception(e)

if conf.get("SILENCE_FAB"):
    logging.getLogger("flask_appbuilder").setLevel(logging.ERROR)

db = SQLA(app)

if conf.get("WTF_CSRF_ENABLED"):
    csrf = CSRFProtect(app)
    csrf_exempt_list = conf.get("WTF_CSRF_EXEMPT_LIST", [])
    for ex in csrf_exempt_list:
        csrf.exempt(ex)

pessimistic_connection_handling(db.engine)

migrate = Migrate(app, db, directory=APP_DIR + "/migrations")

app.config.get("LOGGING_CONFIGURATOR").configure_logging(app.config, app.debug)

if app.config.get("ENABLE_CORS"):
    from flask_cors import CORS

    CORS(app, **app.config.get("CORS_OPTIONS"))

if app.config.get("ENABLE_PROXY_FIX"):
    from werkzeug.middleware.proxy_fix import ProxyFix

    app.wsgi_app = ProxyFix(app.wsgi_app, **app.config.get("PROXY_FIX_CONFIG"))