ModernOSWeather/src/weather.py

16 lines
632 B
Python

from functools import cache
import urllib.request
@cache
def weather_handler(date: str):
print(date)
coordinates = [48.712, 44.514]
url = (
"https://api.open-meteo.com/v1/forecast?latitude="
+ str(coordinates[0])
+ "&longitude="
+ str(coordinates[1])
+ "&current=temperature_2m,relative_humidity_2m,rain,snowfall,weather_code,wind_speed_10m,wind_direction_10m&hourly=temperature_2m,relative_humidity_2m,rain,snowfall,weather_code,wind_speed_10m,wind_direction_10m&timezone=Europe/Moscow&forecast_days=3"
)
raw_data = urllib.request.urlopen(url).read()
return raw_data