modularisierung von app.py und app.js - erster versuch
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# app/__init__.py
|
||||
|
||||
from flask import Flask
|
||||
from .utils.logging import setup_logging
|
||||
from .routes.main import main_bp
|
||||
from .routes.admin import admin_bp
|
||||
from .routes.api import api_bp
|
||||
import threading
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
|
||||
# Config laden
|
||||
app.config.from_object('config.Config')
|
||||
|
||||
# Logging zuerst (vor allem anderen)
|
||||
from .utils.logging import setup_logging, cleanup_old_log_dirs
|
||||
setup_logging(app)
|
||||
|
||||
# Täglicher Cleanup-Thread starten (einmalig)
|
||||
def daily_cleanup():
|
||||
while True:
|
||||
cleanup_old_log_dirs(90)
|
||||
time.sleep(86400) # 24 Stunden
|
||||
|
||||
cleanup_thread = threading.Thread(target=daily_cleanup, daemon=True)
|
||||
cleanup_thread.start()
|
||||
logger.info("Täglicher Log-Cleanup-Thread gestartet (24h Intervall)")
|
||||
|
||||
# Bluetooth initialisieren (Monitor-Thread startet automatisch)
|
||||
from .bluetooth.manager import init_bluetooth
|
||||
init_bluetooth()
|
||||
|
||||
# Blueprints registrieren
|
||||
from .routes.main import main_bp
|
||||
from .routes.admin import admin_bp
|
||||
from .routes.api import api_bp
|
||||
|
||||
# Blueprints registrieren
|
||||
app.register_blueprint(main_bp)
|
||||
app.register_blueprint(admin_bp, url_prefix='/admin')
|
||||
app.register_blueprint(api_bp, url_prefix='/api')
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user