feat: Flask-App-Factory mit Health-Check und QueueHandler
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
from flask import Flask
|
||||
|
||||
from src.queue.handler import QueueHandler
|
||||
|
||||
|
||||
def create_app() -> Flask:
|
||||
"""Erstellt und konfiguriert die Flask-App."""
|
||||
app = Flask(__name__)
|
||||
app.config.from_mapping(
|
||||
REDIS_HOST="localhost",
|
||||
REDIS_PORT=6379,
|
||||
)
|
||||
app.queue_handler = QueueHandler( # type: ignore[attr-defined]
|
||||
redis_host=app.config["REDIS_HOST"],
|
||||
redis_port=app.config["REDIS_PORT"],
|
||||
)
|
||||
|
||||
@app.route("/health")
|
||||
def health() -> dict[str, object]:
|
||||
return {"status": "ok", "queue_size": app.queue_handler.queue_size()} # type: ignore[attr-defined]
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user