"""Application. The API application is a `flask` application. It provides simple features such as registering a url for a specific handlers. """ from flask import Flask from owslogger import flask_logger from owsrequest import flask_request from store import config app = Flask(config.SERVICE_NAME) app.config["SQLALCHEMY_DATABASE_URI"] = config.DB_URL app.config["SQLALCHEMY_ENGINE_OPTIONS"] = config.SQLALCHEMY_ENGINE_OPTIONS app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = config.SQLALCHEMY_TRACK_MODIFICATIONS flask_logger.setup( app, config.ENVIRONMENT, config.LOGGER_NAME, config.LOGGER_LEVEL, config.SERVICE_NAME, config.SERVICE_VERSION, exclude_paths=[config.HEALTH_CHECK], ) try: import uwsgi # noqa:F401 uwsgiRunning = True except ImportError: uwsgiRunning = False flask_request.set_rules_validator(app, "store/access_rules.yml") flask_request.setup( app, config.ENVIRONMENT, verify_access=False, rules_file=None, access_log_only=False, exclude_paths=[config.HEALTH_CHECK], uwsgi_cache_enabled=uwsgiRunning, add_request_context=True, ) if config.ENVIRONMENT in [config.QA_ENVIRONMENT, config.PROD_ENVIRONMENT]: if not config.SENTRY: raise Exception(f"Sentry is not configured in {config.ENVIRONMENT}")