Skip to content

Commit

Permalink
Update Weather
Browse files Browse the repository at this point in the history
correcting the error handling the url
  • Loading branch information
luizfnunes authored Dec 16, 2019
1 parent a65a2ac commit daa57fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions SimplecOne/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

########################################################
main_url = "http://api.openweathermap.org/data/2.5/weather?"
url = main_url+"APPID={}&q={},{}".format(API_KEY,CITY,COUNTRY)
filtered_city = CITY.replace(" ", "%20")
url = main_url+"APPID={}&q={},{}".format(API_KEY,filtered_city,COUNTRY)
metrics = {"k":"&units=default","c":"&units=metric","f":"&units=imperial"}
for key,value in metrics.items():
if UNITY == key:
Expand All @@ -47,4 +48,4 @@
weather.write("wind>"+str(j["wind"]["speed"])+"\n")
weather.write("update>"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+"\n")

weather.close()
weather.close()

0 comments on commit daa57fd

Please sign in to comment.