44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
WSGI-Konfiguration für MYP Backend
|
|
Lädt die Flask-Anwendung für Produktions-Deployment mit Gunicorn
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
|
|
# Füge das Backend-Verzeichnis zum Python-Pfad hinzu
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from app import create_app, init_db, init_printers, setup_frontend_v2
|
|
|
|
# Bestimme die Umgebung
|
|
flask_env = os.environ.get('FLASK_ENV', 'production')
|
|
|
|
# Erstelle die Flask-Anwendung
|
|
application = create_app(flask_env)
|
|
|
|
# Initialisierung für WSGI-Server
|
|
with application.app_context():
|
|
# Datenbank initialisieren
|
|
init_db()
|
|
|
|
# Drucker initialisieren (falls konfiguriert)
|
|
printers_config = application.config.get('PRINTERS', {})
|
|
if printers_config:
|
|
init_printers()
|
|
|
|
# Frontend V2 einrichten
|
|
setup_frontend_v2()
|
|
|
|
# Logging für WSGI-Start
|
|
if hasattr(application, 'logger'):
|
|
application.logger.info(f'MYP Backend WSGI application started in {flask_env} mode')
|
|
|
|
# Export für Gunicorn
|
|
app = application
|
|
|
|
if __name__ == "__main__":
|
|
# Für direkte Ausführung (Debug)
|
|
application.run(host='0.0.0.0', port=5000, debug=(flask_env == 'development')) |