in atr/server.py [0:0]
def create_app(app_config: type[config.AppConfig]) -> base.QuartApp:
"""Create and configure the application."""
app_dirs_setup(app_config)
app = app_create_base(app_config)
app_setup_api_docs(app)
db.init_database(app)
register_routes(app)
blueprints.register(app)
filters.register_filters(app)
config_mode = config.get_mode()
app_setup_context(app)
app_setup_lifecycle(app)
app_setup_logging(app, config_mode, app_config)
# do not enable template pre-loading if we explicitly want to reload templates
if not app_config.TEMPLATES_AUTO_RELOAD:
preload.setup_template_preloading(app)
@app.before_serving
async def start_blockbuster() -> None:
# "I'll have a P, please, Bob."
bb: blockbuster.BlockBuster | None = None
if config_mode == config.Mode.Profiling:
bb = blockbuster.BlockBuster()
app.extensions["blockbuster"] = bb
if bb is not None:
bb.activate()
app.logger.info("Blockbuster activated to detect blocking calls")
@app.after_serving
async def stop_blockbuster() -> None:
bb = app.extensions.get("blockbuster")
if bb is not None:
bb.deactivate()
app.logger.info("Blockbuster deactivated")
return app