Files
BSN-Livesystem/src/app.py
T

34 lines
860 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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