in backend/code_coverage_backend/backend/build.py [0:0]
def build_flask_app(project_name, app_name, openapi):
"""
Create a new Flask backend application
app_name is the Python application name, used as Flask import_name
project_name is a "nice" name, used to identify the application
"""
assert os.path.exists(openapi), "Missing openapi file {}".format(openapi)
logger.debug("Initializing", app=app_name, openapi=openapi)
# Start OpenAPI app
app = connexion.App(import_name=app_name)
app.name = project_name
app.add_api(openapi)
# Enable security
security = flask_talisman.Talisman()
security.init_app(app.app, **TALISMAN_CONFIG)
# Enable wildcard CORS
cors = flask_cors.CORS()
cors.init_app(app.app, origins=["*"])
# Add exception Json renderer
for code, exception in werkzeug.exceptions.default_exceptions.items():
app.app.register_error_handler(exception, handle_default_exceptions)
# Redirect root to API
app.add_url_rule(
"/", "root", lambda: flask.redirect(app.options.openapi_console_ui_path)
)
# Dockerflow checks
app.add_url_rule("/__heartbeat__", view_func=heartbeat_response)
app.add_url_rule("/__lbheartbeat__", view_func=lbheartbeat_response)
app.add_url_rule("/__version__", view_func=get_version)
logger.debug("Initialized", app=app.name)
return app