Files
BSN-Livesystem/src/app.py
T

42 lines
1.1 KiB
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 __future__ import annotations
from flask import Flask
from src.config import settings
from src.error_handler import register_error_handlers
from src.logging_config import setup_logging
from src.queue.handler import QueueHandler
from src.routes.admin import admin_bp
from src.routes.health import health_bp
from src.routes.telegram import telegram_bp
from src.routes.whatsapp import whatsapp_bp
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__)
setup_logging()
register_error_handlers(app)
app.queue_handler = QueueHandler(
redis_host=settings.REDIS_HOST,
redis_port=settings.REDIS_PORT,
)
app.register_blueprint(telegram_bp, url_prefix="/webhook")
app.register_blueprint(whatsapp_bp, url_prefix="/webhook")
app.register_blueprint(admin_bp, url_prefix="/admin")
app.register_blueprint(health_bp)
return app