Compare commits
3 Commits
52400f888e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2112af7794 | |||
| b559d5660d | |||
| 3e05f6ff74 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,3 +2,7 @@ utils/__pycache__/__init__.cpython-313.pyc
|
|||||||
utils/__pycache__/geocode.cpython-313.pyc
|
utils/__pycache__/geocode.cpython-313.pyc
|
||||||
utils/__pycache__/weather.cpython-313.pyc
|
utils/__pycache__/weather.cpython-313.pyc
|
||||||
__pycache__/config.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
|
||||||
|
|||||||
@@ -18,5 +18,6 @@ COPY static/ ./static
|
|||||||
# Expose the Flask port
|
# Expose the Flask port
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
# Run the app with Gunicorn
|
# Run the app with Gunicorn, 4 workers, 2 threads each
|
||||||
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
|
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app", "-w", "4", "--threads", "2"]
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ requests
|
|||||||
gunicorn
|
gunicorn
|
||||||
pytz
|
pytz
|
||||||
timezonefinder
|
timezonefinder
|
||||||
Flask-Caching
|
Flask-Caching
|
||||||
|
httpx
|
||||||
|
|||||||
@@ -10,21 +10,21 @@ async def get_today_snowfall_async(lat, lon):
|
|||||||
tz_name = tf.timezone_at(lat=lat, lng=lon) or "UTC"
|
tz_name = tf.timezone_at(lat=lat, lng=lon) or "UTC"
|
||||||
|
|
||||||
async with httpx.AsyncClient(timeout=5) as client:
|
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 = await client.get(OPEN_METEO_URL, params=params)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
|
||||||
hourly = data.get("hourly", {})
|
daily = data.get("daily", {})
|
||||||
times = hourly.get("time", [])
|
days = daily.get("time", [])
|
||||||
snow_values = hourly.get("snowfall", [])
|
snow_values = daily.get("snowfall_sum", [])
|
||||||
|
|
||||||
today_str = datetime.now(pytz.timezone(tz_name)).date().isoformat()
|
today_str = datetime.now(pytz.timezone(tz_name)).date().isoformat()
|
||||||
|
|
||||||
snowfall_cm = 0.0
|
snowfall_cm = 0.0
|
||||||
snowing_now = False
|
snowing_now = False
|
||||||
for t, s in zip(times, snow_values):
|
for d, s in zip(days, snow_values):
|
||||||
if t.startswith(today_str):
|
if d.startswith(today_str):
|
||||||
snowfall_cm += s
|
snowfall_cm += s
|
||||||
if s > 0:
|
if s > 0:
|
||||||
snowing_now = True
|
snowing_now = True
|
||||||
|
|||||||
Reference in New Issue
Block a user