17 lines
444 B
Python
17 lines
444 B
Python
import json
|
|
import requests
|
|
import os
|
|
|
|
#based on
|
|
URL = "https://worldweather.wmo.int/en/json/{city_id}_en.json"
|
|
URL = "https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={api_key}"
|
|
|
|
|
|
def weather(api_key=os.getenv('openweathermap_api_key'), lat="41.98", lon="-87.90"):
|
|
url = URL.format(api_key=api_key, lat=lat, lon=lon)
|
|
data = json.loads(requests.get(url).content)
|
|
|
|
return data['weather'][0]
|
|
|
|
f=weather()
|
|
pass |