30 lines
661 B
Python
30 lines
661 B
Python
"""Quart app factory."""
|
|
|
|
import logging
|
|
|
|
from quart import Quart
|
|
|
|
from .api import all_blueprints
|
|
from .config import get_config
|
|
from .frontend import frontend_bp
|
|
|
|
|
|
def create_app() -> Quart:
|
|
cfg = get_config()
|
|
logging.basicConfig(level=cfg.log_level)
|
|
|
|
app = Quart(__name__)
|
|
app.secret_key = cfg.secret_key
|
|
|
|
for bp in all_blueprints():
|
|
app.register_blueprint(bp)
|
|
# Registered last so /api/* routes win over the SPA catch-all.
|
|
app.register_blueprint(frontend_bp)
|
|
|
|
@app.after_serving
|
|
async def _dispose_db_engine() -> None:
|
|
from .extensions import dispose_engine
|
|
await dispose_engine()
|
|
|
|
return app
|