-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (27 loc) · 899 Bytes
/
app.py
File metadata and controls
34 lines (27 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import time
from flask import Flask
from dotenv import load_dotenv
from config import MQTT_CONFIG
from database import init_db, self_heal_daily_stats, force_rebuild_daily_stats
from ml_logic import load_or_train_model
from mqtt_handler import init_mqtt
from routes import api_bp
# System-Einstellungen
os.environ['TZ'] = 'Europe/Berlin'
if hasattr(time, 'tzset'):
time.tzset()
load_dotenv()
app = Flask(__name__, template_folder='templates')
app.config.update(MQTT_CONFIG)
# Initialisierung
mqtt = init_mqtt(app)
app.register_blueprint(api_bp)
if __name__ == '__main__':
init_db()
# 🔥 EINMAL ausführen, danach wieder auskommentieren!
# force_rebuild_daily_stats()
self_heal_daily_stats()
print("System erfolgreich gestartet. Warte auf Daten...")
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port, use_reloader=False)