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__/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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
@@ -4,3 +4,4 @@ gunicorn
|
||||
pytz
|
||||
timezonefinder
|
||||
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"
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user