def create_app()

in api-server/tesazure/__init__.py [0:0]


def create_app(config=config.base_config):
    """Returns an initialized Flask application."""
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(config)

    register_extensions(app)
    register_blueprints(app)
    register_jinja_env(app)
    register_commands(app)

    load_keyvault_config(app)
    validate_config(app)

    def get_locale():
        """Returns the locale to be used for the incoming request."""
        return request.accept_languages.best_match(config.SUPPORTED_LOCALES)

    if babel.locale_selector_func is None:
        babel.locale_selector_func = get_locale

    @app.before_request
    def before_request():
        """Prepare some things before the application handles a request."""
        g.request_start_time = time.time()
        g.request_time = lambda: '%.5fs' % (time.time() - g.request_start_time)
        g.pjax = 'X-PJAX' in request.headers

    @app.route('/', methods=['GET'])
    def index():
        """Returns the applications index page."""
        return render_template('index.html')

    app.logger.info(f'Successfully started {app.config["SITE_NAME"]}.')
    return app