41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import os
|
|
|
|
from flask import Flask, jsonify
|
|
|
|
from l4d2web.auth import load_current_user
|
|
from l4d2web.cli import register_cli
|
|
from l4d2web.config import DEFAULT_CONFIG
|
|
from l4d2web.db import init_db
|
|
from l4d2web.routes.blueprint_routes import bp as blueprint_bp
|
|
from l4d2web.routes.auth_routes import bp as auth_bp
|
|
from l4d2web.routes.overlay_routes import bp as overlay_bp
|
|
from l4d2web.routes.server_routes import bp as server_bp
|
|
from l4d2web.services.job_worker import recover_stale_jobs
|
|
|
|
|
|
def create_app(test_config: dict[str, object] | None = None) -> Flask:
|
|
app = Flask(__name__)
|
|
app.config.from_mapping(DEFAULT_CONFIG)
|
|
if test_config is not None:
|
|
app.config.update(test_config)
|
|
|
|
os.environ["DATABASE_URL"] = str(app.config["DATABASE_URL"])
|
|
init_db()
|
|
|
|
app.before_request(load_current_user)
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(overlay_bp)
|
|
app.register_blueprint(blueprint_bp)
|
|
app.register_blueprint(server_bp)
|
|
register_cli(app)
|
|
recover_stale_jobs()
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return jsonify({"status": "ok"})
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return jsonify({"status": "ok"})
|
|
|
|
return app
|