def create_app(run_mode=os.getenv('FLASK_ENV', 'production')): """Return a configured Flask App using the Factory method.""" app = Flask(__name__) app.config.from_object(config.CONFIGURATION[run_mode]) # Configure Sentry if app.config.get('SENTRY_DSN', None): sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'), integrations=[FlaskIntegration()]) errorhandlers.init_app(app) db.init_app(app) ma.init_app(app) rsbc_schemas.init_app(app) flags.init_app(app) queue.init_app(app) babel.init_app(app) app.register_blueprint(API_BLUEPRINT) app.register_blueprint(OPS_BLUEPRINT) setup_jwt_manager(app, jwt) @app.route('/') def be_nice_swagger_redirect(): # pylint: disable=unused-variable return redirect('/api/v1', code=HTTPStatus.MOVED_PERMANENTLY) @app.after_request def add_version(response): # pylint: disable=unused-variable version = get_run_version() response.headers['API'] = f'legal_api/{version}' return response register_shellcontext(app) return app
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')): """Return a configured Flask App using the Factory method.""" app = Flask(__name__) app.config.from_object(config.CONFIGURATION[run_mode]) db.init_app(app) rsbc_schemas.init_app(app) # Register blueprints app.register_blueprint(FIXTURE_BLUEPRINT) # Shell context for flask cli @app.shell_context_processor def ctx(): # pylint: disable=unused-variable return {'app': app, 'db': db} return app
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')): """Return a configured Flask App using the Factory method.""" app = Flask(__name__) app.config.from_object(config.CONFIGURATION[run_mode]) # # Configure Sentry # if app.config.get('SENTRY_DSN', None): # sentry_sdk.init( # dsn=app.config.get('SENTRY_DSN'), # integrations=[FlaskIntegration()] # ) db.init_app(app) rsbc_schemas.init_app(app) # Register blueprints app.register_blueprint(fixture_blueprint) # Shell context for flask cli @app.shell_context_processor def ctx(): return {'app': app, 'db': db} return app
"""Return a configured Flask App using the Factory method.""" app = Flask(__name__) app.config.from_object(config.CONFIGURATION[run_mode]) # Configure Sentry if dsn := app.config.get('SENTRY_DSN', None): # pylint==2.7.4 errors out on the syntatic sugar for sentry_sdk # the error is skipped by disable=abstract-class-instantiated sentry_sdk.init( # pylint: disable=abstract-class-instantiated dsn=dsn, integrations=[FlaskIntegration()], send_default_pii=False ) db.init_app(app) rsbc_schemas.init_app(app) flags.init_app(app) queue.init_app(app) babel.init_app(app) endpoints.init_app(app) setup_jwt_manager(app, jwt) register_shellcontext(app) return app def setup_jwt_manager(app, jwt_manager): """Use flask app to configure the JWTManager to work for a particular Realm.""" def get_roles(a_dict):