modified: __pycache__/app.cpython-310.pyc
modified: app.py modified: templates/weather.html
This commit is contained in:
13
app.py
13
app.py
@@ -5,6 +5,7 @@ from geopy.exc import GeocoderTimedOut
|
||||
import math
|
||||
import traceback
|
||||
import pandas as pd
|
||||
import datetime as _dt
|
||||
|
||||
from wetterdienst.provider.dwd.mosmix import DwdMosmixRequest
|
||||
|
||||
@@ -199,7 +200,15 @@ def wetter():
|
||||
station_lon = float(mosmix_station.get("longitude", lon))
|
||||
station_dist = round(haversine(lat, lon, station_lat, station_lon), 1)
|
||||
|
||||
# "Aktuell" = erste Stunde >= jetzt (UTC), sonst erste verfügbare
|
||||
now_utc = _dt.datetime.now(_dt.timezone.utc).replace(tzinfo=None)
|
||||
current = forecast[0]
|
||||
for h in forecast:
|
||||
dt = h["datetime"]
|
||||
dt_naive = dt.replace(tzinfo=None) if hasattr(dt, "tzinfo") and dt.tzinfo is not None else dt
|
||||
if dt_naive >= now_utc:
|
||||
current = h
|
||||
break
|
||||
|
||||
# Tageszusammenfassung
|
||||
daily = {}
|
||||
@@ -233,7 +242,7 @@ def wetter():
|
||||
})
|
||||
|
||||
# Chart-Daten (erste 48 h)
|
||||
chart_labels, chart_temps, chart_precip = [], [], []
|
||||
chart_labels, chart_temps, chart_precip, chart_rain_prob = [], [], [], []
|
||||
for h in forecast[:48]:
|
||||
dt = h["datetime"]
|
||||
label = (dt.strftime("%d.%m %H:%M") if hasattr(dt, "strftime")
|
||||
@@ -241,6 +250,7 @@ def wetter():
|
||||
chart_labels.append(label)
|
||||
chart_temps.append(h["temp_c"])
|
||||
chart_precip.append(h.get("precip_mm") or 0)
|
||||
chart_rain_prob.append(h.get("rain_prob") or 0)
|
||||
|
||||
return render_template(
|
||||
"weather.html",
|
||||
@@ -257,6 +267,7 @@ def wetter():
|
||||
chart_labels=chart_labels,
|
||||
chart_temps=chart_temps,
|
||||
chart_precip=chart_precip,
|
||||
chart_rain_prob=chart_rain_prob,
|
||||
wind_dir_name=wind_direction_name,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user