initial feature/react-migration commit
This commit is contained in:
79
dashboard-dash-backup/app.py
Normal file
79
dashboard-dash-backup/app.py
Normal file
@@ -0,0 +1,79 @@
|
||||
# dashboard/app.py
|
||||
import sys
|
||||
sys.path.append('/workspace')
|
||||
|
||||
from dash import Dash, html, dcc, page_container
|
||||
from flask import Flask
|
||||
import dash_bootstrap_components as dbc
|
||||
import dash_mantine_components as dmc
|
||||
from components.header import Header
|
||||
import callbacks.ui_callbacks
|
||||
import dashboard.callbacks.overview_callbacks
|
||||
import dashboard.callbacks.appointments_callbacks
|
||||
import dashboard.callbacks.appointment_modal_callbacks
|
||||
from config import SECRET_KEY, ENV
|
||||
import os
|
||||
import threading
|
||||
import logging
|
||||
|
||||
# Logging konfigurieren
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG if ENV == "development" else logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
server = Flask(__name__)
|
||||
server.secret_key = SECRET_KEY
|
||||
|
||||
# Flask's eigene Logs aktivieren
|
||||
if ENV == "development":
|
||||
logging.getLogger('werkzeug').setLevel(logging.INFO)
|
||||
|
||||
app = Dash(
|
||||
__name__,
|
||||
server=server,
|
||||
use_pages=True,
|
||||
external_stylesheets=[dbc.themes.BOOTSTRAP],
|
||||
suppress_callback_exceptions=True,
|
||||
serve_locally=True,
|
||||
meta_tags=[
|
||||
{"name": "viewport", "content": "width=device-width, initial-scale=1"},
|
||||
{"charset": "utf-8"}
|
||||
]
|
||||
)
|
||||
|
||||
app.layout = dmc.MantineProvider([
|
||||
Header(),
|
||||
html.Div([
|
||||
html.Div(id="sidebar"),
|
||||
html.Div(page_container, className="page-content"),
|
||||
dcc.Store(id="sidebar-state", data={"collapsed": False}),
|
||||
], style={"display": "flex"}),
|
||||
])
|
||||
|
||||
# def open_browser():
|
||||
# """Öffnet die HTTPS-URL im Standardbrowser."""
|
||||
# os.system('$BROWSER https://localhost:8050') # Entferne das "&", um sicherzustellen, dass der Browser korrekt geöffnet wird
|
||||
|
||||
print("Testausgabe: Debug-Print funktioniert!") # Testausgabe
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug_mode = ENV == "development"
|
||||
|
||||
logger.info(f"Starting application in {'DEBUG' if debug_mode else 'PRODUCTION'} mode")
|
||||
logger.info(f"Environment: {ENV}")
|
||||
logger.info("🔧 Debug features: print(), logging, hot reload all active")
|
||||
logger.info("🚀 Dashboard starting up...")
|
||||
|
||||
# Browser nur einmal öffnen, nicht bei Reload-Prozessen
|
||||
# if debug_mode and os.environ.get("WERKZEUG_RUN_MAIN") != "true":
|
||||
# threading.Timer(1.0, open_browser).start()
|
||||
|
||||
app.run(
|
||||
host="0.0.0.0",
|
||||
port=8050,
|
||||
debug=debug_mode,
|
||||
ssl_context=("/workspace/certs/dev.crt", "/workspace/certs/dev.key"),
|
||||
use_reloader=False # Verhindert doppeltes Öffnen durch Dash
|
||||
)
|
||||
Reference in New Issue
Block a user