Set all requests to ssl
This commit is contained in:
@@ -2,44 +2,78 @@
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append('/workspace')
|
sys.path.append('/workspace')
|
||||||
|
|
||||||
from dash import Dash, html, dcc, page_container, Output, Input, State, callback
|
from dash import Dash, html, dcc, page_container
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
import dash_bootstrap_components as dbc
|
import dash_bootstrap_components as dbc
|
||||||
import dash_mantine_components as dmc
|
import dash_mantine_components as dmc
|
||||||
from components.header import Header
|
from components.header import Header
|
||||||
# from components.sidebar import Sidebar
|
import callbacks.ui_callbacks
|
||||||
import callbacks.ui_callbacks # wichtig!
|
import dashboard.callbacks.overview_callbacks
|
||||||
import dashboard.callbacks.overview_callbacks # <-- Das registriert die Callbacks
|
|
||||||
import dashboard.callbacks.appointments_callbacks
|
import dashboard.callbacks.appointments_callbacks
|
||||||
import dashboard.callbacks.appointment_modal_callbacks
|
import dashboard.callbacks.appointment_modal_callbacks
|
||||||
from config import SECRET_KEY, ENV
|
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 = Flask(__name__)
|
||||||
server.secret_key = SECRET_KEY
|
server.secret_key = SECRET_KEY
|
||||||
|
|
||||||
|
# Flask's eigene Logs aktivieren
|
||||||
|
if ENV == "development":
|
||||||
|
logging.getLogger('werkzeug').setLevel(logging.INFO)
|
||||||
|
|
||||||
app = Dash(
|
app = Dash(
|
||||||
__name__,
|
__name__,
|
||||||
server=server,
|
server=server,
|
||||||
use_pages=True,
|
use_pages=True,
|
||||||
external_stylesheets=[dbc.themes.BOOTSTRAP],
|
external_stylesheets=[dbc.themes.BOOTSTRAP],
|
||||||
suppress_callback_exceptions=True,
|
suppress_callback_exceptions=True,
|
||||||
serve_locally=True
|
serve_locally=True,
|
||||||
|
meta_tags=[
|
||||||
|
{"name": "viewport", "content": "width=device-width, initial-scale=1"},
|
||||||
|
{"charset": "utf-8"}
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
app.layout = dmc.MantineProvider([
|
app.layout = dmc.MantineProvider([
|
||||||
Header(),
|
Header(),
|
||||||
html.Div([
|
html.Div([
|
||||||
html.Div(id="sidebar"), # KEINE className="sidebar" hier!
|
html.Div(id="sidebar"),
|
||||||
html.Div(page_container, className="page-content"),
|
html.Div(page_container, className="page-content"),
|
||||||
dcc.Store(id="sidebar-state", data={"collapsed": False}),
|
dcc.Store(id="sidebar-state", data={"collapsed": False}),
|
||||||
], style={"display": "flex"}),
|
], 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__":
|
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(
|
app.run(
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
port=8050,
|
port=8050,
|
||||||
debug=(ENV=="development"),
|
debug=debug_mode,
|
||||||
ssl_context=("/workspace/certs/dev.crt", "/workspace/certs/dev.key")
|
ssl_context=("/workspace/certs/dev.crt", "/workspace/certs/dev.key"),
|
||||||
)
|
use_reloader=False # Verhindert doppeltes Öffnen durch Dash
|
||||||
|
)
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
import logging
|
||||||
|
from math import fabs
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
# dashboard/callbacks/appointments_callbacks.py
|
# dashboard/callbacks/appointments_callbacks.py
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
@@ -7,6 +11,10 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
# This message will now appear in the terminal during startup
|
||||||
|
logger.debug("Registering appointments page...")
|
||||||
|
|
||||||
|
|
||||||
# --- Modalbox öffnen: jetzt auch auf Kalenderklick reagieren ---
|
# --- Modalbox öffnen: jetzt auch auf Kalenderklick reagieren ---
|
||||||
|
|
||||||
sys.path.append('/workspace')
|
sys.path.append('/workspace')
|
||||||
@@ -14,6 +22,7 @@ sys.path.append('/workspace')
|
|||||||
print("appointments_callbacks.py geladen")
|
print("appointments_callbacks.py geladen")
|
||||||
|
|
||||||
API_BASE_URL = os.getenv("API_BASE_URL", "http://192.168.43.100")
|
API_BASE_URL = os.getenv("API_BASE_URL", "http://192.168.43.100")
|
||||||
|
ENV = os.getenv("ENV", "development")
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
@@ -51,22 +60,23 @@ def display_select(select_info):
|
|||||||
dash.Input('calendar', 'lastNavClick'),
|
dash.Input('calendar', 'lastNavClick'),
|
||||||
)
|
)
|
||||||
def load_events(view_dates):
|
def load_events(view_dates):
|
||||||
"""
|
logger.info(f"Lade Events für Zeitraum: {view_dates}")
|
||||||
Lädt Events aus der API für den angezeigten Zeitraum im Kalender.
|
|
||||||
"""
|
|
||||||
print("Lade Events für Zeitraum:", view_dates)
|
|
||||||
if not view_dates or "start" not in view_dates or "end" not in view_dates:
|
if not view_dates or "start" not in view_dates or "end" not in view_dates:
|
||||||
return []
|
return []
|
||||||
start = view_dates["start"]
|
start = view_dates["start"]
|
||||||
end = view_dates["end"]
|
end = view_dates["end"]
|
||||||
try:
|
try:
|
||||||
resp = requests.get(f"{API_BASE_URL}/api/events",
|
verify_ssl = True if ENV == "production" else False
|
||||||
params={"start": start, "end": end})
|
resp = requests.get(
|
||||||
|
f"{API_BASE_URL}/api/events",
|
||||||
|
params={"start": start, "end": end},
|
||||||
|
verify=verify_ssl
|
||||||
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
events = resp.json()
|
events = resp.json()
|
||||||
return events
|
return events
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Fehler beim Laden der Events:", e)
|
logger.info(f"Fehler beim Laden der Events: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# --- Modalbox öffnen ---
|
# --- Modalbox öffnen ---
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
print("overview_callbacks.py geladen")
|
print("overview_callbacks.py geladen")
|
||||||
|
|
||||||
API_BASE_URL = os.getenv("API_BASE_URL", "http://192.168.43.100")
|
API_BASE_URL = os.getenv("API_BASE_URL", "https://192.168.43.100")
|
||||||
|
|
||||||
mqtt_thread_started = False
|
mqtt_thread_started = False
|
||||||
SCREENSHOT_DIR = "received-screenshots"
|
SCREENSHOT_DIR = "received-screenshots"
|
||||||
@@ -40,7 +40,11 @@ def get_latest_screenshot(client_uuid):
|
|||||||
|
|
||||||
def fetch_clients():
|
def fetch_clients():
|
||||||
try:
|
try:
|
||||||
resp = requests.get(f"{API_BASE_URL}/api/clients")
|
verify_ssl = True if ENV == "production" else False
|
||||||
|
resp = requests.get(
|
||||||
|
f"{API_BASE_URL}/api/clients",
|
||||||
|
verify=verify_ssl
|
||||||
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json()
|
return resp.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user