PUBLIC_URL: Kalender-Link per Umgebungsvariable (HTTPS hinter Proxy)

This commit is contained in:
2026-01-29 14:02:44 +01:00
parent 221e9eb8d6
commit 51e7cdd85c
3 changed files with 11 additions and 4 deletions

4
app.py
View File

@@ -19,6 +19,8 @@ from kantine2ical import BASE_URL, empty_ical_bytes, refresh_speiseplan
# Konfiguration (Umgebungsvariablen mit Fallback)
KANTINE_BASE_URL = os.environ.get("KANTINE_BASE_URL", BASE_URL)
REFRESH_INTERVAL_SECONDS = int(os.environ.get("REFRESH_INTERVAL_SECONDS", "86400")) # 24h
# Öffentliche Basis-URL (z. B. https://kantine.elpatron.me), wenn Proxy keine X-Forwarded-* sendet
PUBLIC_URL = os.environ.get("PUBLIC_URL", "").strip().rstrip("/")
# Template-Ordner immer relativ zu dieser Datei (funktioniert mit Gunicorn/Docker)
_template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
@@ -90,7 +92,7 @@ def _format_last_refresh() -> str | None:
@app.route("/")
def index():
"""Startseite mit Anleitung zur iCal-Einbettung (Google und andere)."""
base = request.url_root.rstrip("/")
base = PUBLIC_URL or request.url_root.rstrip("/")
calendar_url = f"{base}/calendar.ics"
last_refresh_str = _format_last_refresh()
try: