Fix: .env wird automatisch geladen (MQTT-Events kamen nicht an)
Ohne 'source .env' liefen Broker/Topic auf Defaults (127.0.0.1 statt 192.168.10.7, vehiclecounter/cam1 statt counter/cam1) -> keine Events. Jetzt laedt app.py die .env per python-dotenv beim Start. - load_dotenv() vor dem Auslesen von os.environ - README: .env-Konfig + supervisord-Hinweis (directory=), python-dotenv Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
8
app.py
8
app.py
@@ -26,6 +26,14 @@ from flask import (
|
||||
from werkzeug.utils import secure_filename
|
||||
from ultralytics import YOLO
|
||||
|
||||
# .env laden, BEVOR os.environ ausgelesen wird (Broker-/Kamera-/MQTT-Konfig).
|
||||
# load_dotenv versteht auch "export VAR=..."-Zeilen und Inline-Kommentare.
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
print("[config] python-dotenv nicht installiert - .env wird ignoriert", flush=True)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Konfiguration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user