add weather
This commit is contained in:
17
app/weather.py
Normal file
17
app/weather.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
Reference in New Issue
Block a user