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]) # start tracer tracer = init_tracer(__name__) FlaskTracing(tracer) from auth_api import models from auth_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) setup_jwt_manager(app, jwt) @app.after_request def add_version(response): # pylint: disable=unused-variable version = get_run_version() response.headers['API'] = f'auth_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(CONFIGURATION[run_mode]) # Configure Sentry if app.config.get('SENTRY_DSN', None): sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'), integrations=[FlaskIntegration()]) from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT # pylint: disable=import-outside-toplevel db.init_app(app) ma.init_app(app) mail.init_app(app) app.register_blueprint(API_BLUEPRINT) app.register_blueprint(OPS_BLUEPRINT) setup_jwt_manager(app, JWT) ExceptionHandler(app) @app.after_request def add_version(response): # pylint: disable=unused-variable version = get_run_version() response.headers['API'] = f'auth_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]) # Configure Sentry if str(app.config.get('SENTRY_ENABLE')).lower() == 'true': if app.config.get('SENTRY_DSN', None): sentry_sdk.init( # pylint: disable=abstract-class-instantiated dsn=app.config.get('SENTRY_DSN'), integrations=[FlaskIntegration()]) from auth_api.resources import TEST_BLUEPRINT # pylint: disable=import-outside-toplevel from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT # pylint: disable=import-outside-toplevel db.init_app(app) ma.init_app(app) mail.init_app(app) app.register_blueprint(API_BLUEPRINT) app.register_blueprint(OPS_BLUEPRINT) if os.getenv('FLASK_ENV', 'production') in ['development', 'testing']: app.register_blueprint(TEST_BLUEPRINT) if os.getenv('FLASK_ENV', 'production') != 'testing': setup_jwt_manager(app, jwt) ExceptionHandler(app) @app.before_request def set_origin(): g.origin_url = request.environ.get('HTTP_ORIGIN', 'localhost') @app.after_request def handle_after_request(response): # pylint: disable=unused-variable add_version(response) camelize_json(response) return response def add_version(response): version = get_run_version() response.headers['API'] = f'auth_api/{version}' def camelize_json(response): if (response.headers['Content-Type'] == 'application/json' and 'swagger.json' not in request.base_url): response.set_data( json.dumps(camelize(json.loads(response.get_data())))) register_shellcontext(app) build_cache(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]) # Configure Sentry if app.config.get('SENTRY_DSN', None): sentry_sdk.init( dsn=app.config.get('SENTRY_DSN'), integrations=[FlaskIntegration()] ) from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT, \ TEST_BLUEPRINT # pylint: disable=import-outside-toplevel db.init_app(app) ma.init_app(app) mail.init_app(app) app.register_blueprint(API_BLUEPRINT) app.register_blueprint(OPS_BLUEPRINT) if os.getenv('FLASK_ENV', 'production') in ['development', 'testing']: app.register_blueprint(TEST_BLUEPRINT) if os.getenv('FLASK_ENV', 'production') != 'testing': setup_jwt_manager(app, JWT) ExceptionHandler(app) @app.after_request def handle_after_request(response): # pylint: disable=unused-variable add_version(response) camelize_json(response) return response def add_version(response): version = get_run_version() response.headers['API'] = f'auth_api/{version}' def camelize_json(response): if response.headers['Content-Type'] == 'application/json': response.set_data(json.dumps(camelize(json.loads(response.get_data())))) register_shellcontext(app) build_cache(app) return app
from account_mailer.auth_utils import get_member_emails from account_mailer.email_processors import common_mailer # pylint: disable=wrong-import-order from account_mailer.email_processors import ejv_failures # pylint: disable=wrong-import-order from account_mailer.email_processors import pad_confirmation # pylint: disable=wrong-import-order from account_mailer.email_processors import payment_completed # pylint: disable=wrong-import-order from account_mailer.email_processors import refund_requested # pylint: disable=wrong-import-order from account_mailer.enums import MessageType, SubjectType, TemplateType from account_mailer.services import minio_service # pylint: disable=wrong-import-order from account_mailer.services import notification_service # pylint: disable=wrong-import-order qsm = QueueServiceManager() # pylint: disable=invalid-name APP_CONFIG = config.get_named_config(os.getenv('DEPLOYMENT_ENV', 'production')) FLASK_APP = Flask(__name__) FLASK_APP.config.from_object(APP_CONFIG) db.init_app(FLASK_APP) # pylint: disable=too-many-statements, too-many-branches async def process_event(event_message: dict, flask_app): """Process the incoming queue event message.""" if not flask_app: raise QueueException('Flask App not available.') with flask_app.app_context(): message_type = event_message.get('type', None) email_msg = event_message.get('data') email_msg['logo_url'] = minio_service.MinioService.get_minio_public_url('bc_logo_for_email.png') email_dict = None token = RestService.get_service_account_token() logger.debug('message_type recieved %s', message_type)