from flask import Flask from sentry_sdk.integrations.flask import FlaskIntegration # noqa: I001 from sbc_common_components.exception_handling.exception_handler import ExceptionHandler # noqa: I001 from sbc_common_components.utils.camel_case_response import convert_to_camel import config from config import _Config from pay_api.models import db, ma from pay_api.utils.auth import jwt from pay_api.utils.logging import setup_logging from pay_api.utils.run_version import get_run_version import sentry_sdk # noqa: I001; pylint: disable=ungrouped-imports,wrong-import-order; conflicts with Flake8 setup_logging(os.path.join(_Config.PROJECT_ROOT, 'logging.conf')) 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): # pragma: no cover sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'), integrations=[FlaskIntegration()]) # pylint: disable=import-outside-toplevel from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT db.init_app(app)
""" import os from flask import Flask from sbc_common_components.exception_handling.exception_handler import ExceptionHandler from sbc_common_components.utils.camel_case_response import convert_to_camel import config from config import _Config from pay_api.models import db, ma from pay_api.utils.auth import jwt from pay_api.utils.logging import setup_logging from pay_api.utils.run_version import get_run_version setup_logging(os.path.join(_Config.PROJECT_ROOT, 'logging.conf')) # important to do this first 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]) from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT db.init_app(app) ma.init_app(app) app.register_blueprint(API_BLUEPRINT) app.register_blueprint(OPS_BLUEPRINT) app.after_request(convert_to_camel)
""" import os from flask import Flask from flask_jwt_oidc import JwtManager import config from pay_api import models from pay_api.models import db, ma from pay_api.utils.logging import setup_logging from pay_api.utils.run_version import get_run_version from sbc_common_components.tracing.api_tracer import ApiTracer from sbc_common_components.tracing.api_tracing import ApiTracing setup_logging( os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logging.conf')) # important to do this first # lower case name as used by convention in most Flask apps jwt = JwtManager() # pylint: disable=invalid-name tracing = None # pylint: disable=invalid-name 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]) # initialize tracer api_tracer = ApiTracer("Payment Services") global tracing # pylint: disable=global-statement,invalid-name