"""Application. The API application is a `flask` application. It provides simple features such as registering a url for a specific handlers. """ import logging from flask import Flask from owslogger import flask_logger from owsrequest import flask_request from asset_transcoder import config from asset_transcoder.connectors import sentry app = Flask(config.SERVICE_NAME) if config.SENTRY: sentry.init_sentry(config.SENTRY) 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 uwsgiRunning = True except ImportError: uwsgiRunning = False flask_request.setup(app, config.ENVIRONMENT, uwsgi_cache_enabled=uwsgiRunning, add_request_context=True) if config.ENVIRONMENT == config.DEV_ENVIRONMENT: try: from flasgger import Swagger app.config['SWAGGER'] = { 'title': 'ows-asset-trancoder Documentation', 'uiversion': 2 } Swagger(app, template_file=config.SWAGGER_FILE_PATH) except ModuleNotFoundError: logging.warning('Cannot import flasgger. Go on without swagger.') except Exception: print('Could not find swagger file at {}'.format( config.SWAGGER_FILE_PATH))