Compare commits

...

3 Commits

Author SHA1 Message Date
2112af7794 change calculation to strictly days 2026-01-25 14:30:02 -05:00
b559d5660d beef up gunicorn 2026-01-24 19:23:26 -05:00
3e05f6ff74 adds httpx 2026-01-24 19:10:27 -05:00
4 changed files with 15 additions and 9 deletions

4
.gitignore vendored
View File

@@ -2,3 +2,7 @@ utils/__pycache__/__init__.cpython-313.pyc
utils/__pycache__/geocode.cpython-313.pyc
utils/__pycache__/weather.cpython-313.pyc
__pycache__/config.cpython-313.pyc
__pycache__/config.cpython-312.pyc
utils/__pycache__/geocode.cpython-312.pyc
utils/__pycache__/weather.cpython-312.pyc
utils/__pycache__/__init__.cpython-312.pyc

View File

@@ -18,5 +18,6 @@ COPY static/ ./static
# Expose the Flask port
EXPOSE 5000
# Run the app with Gunicorn
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
# Run the app with Gunicorn, 4 workers, 2 threads each
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app", "-w", "4", "--threads", "2"]

View File

@@ -3,4 +3,5 @@ requests
gunicorn
pytz
timezonefinder
Flask-Caching
Flask-Caching
httpx

View File

@@ -10,21 +10,21 @@ async def get_today_snowfall_async(lat, lon):
tz_name = tf.timezone_at(lat=lat, lng=lon) or "UTC"
async with httpx.AsyncClient(timeout=5) as client:
params = {"latitude": lat, "longitude": lon, "hourly": "snowfall", "timezone": tz_name}
params = {"latitude": lat, "longitude": lon, "daily": "snowfall_sum", "timezone": tz_name}
r = await client.get(OPEN_METEO_URL, params=params)
r.raise_for_status()
data = r.json()
hourly = data.get("hourly", {})
times = hourly.get("time", [])
snow_values = hourly.get("snowfall", [])
daily = data.get("daily", {})
days = daily.get("time", [])
snow_values = daily.get("snowfall_sum", [])
today_str = datetime.now(pytz.timezone(tz_name)).date().isoformat()
snowfall_cm = 0.0
snowing_now = False
for t, s in zip(times, snow_values):
if t.startswith(today_str):
for d, s in zip(days, snow_values):
if d.startswith(today_str):
snowfall_cm += s
if s > 0:
snowing_now = True