34 lines
860 B
Python
34 lines
860 B
Python
"""Flask App-Factory – Einstiegspunkt des BSN-Livesystems."""
|
||
|
||
from flask import Flask, jsonify
|
||
|
||
from src.queue.handler import QueueHandler
|
||
|
||
|
||
def create_app() -> Flask:
|
||
"""Erstellt und konfiguriert die Flask-App.
|
||
|
||
Nutzt das App-Factory-Pattern für saubere Initialisierung.
|
||
Der QueueHandler wird als App-Extension hinterlegt.
|
||
|
||
Returns:
|
||
Die konfigurierte Flask-App-Instanz.
|
||
"""
|
||
app = Flask(__name__)
|
||
app.config.from_mapping(
|
||
REDIS_HOST="localhost",
|
||
REDIS_PORT=6379,
|
||
)
|
||
|
||
app.queue_handler = QueueHandler(
|
||
redis_host=app.config["REDIS_HOST"],
|
||
redis_port=app.config["REDIS_PORT"],
|
||
)
|
||
|
||
@app.route("/health")
|
||
def health() -> dict:
|
||
"""Health-Check Endpoint für Monitoring."""
|
||
return {"status": "ok", "queue_size": app.queue_handler.queue_size()}
|
||
|
||
return app
|