Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 17, 2025
1 parent 04d25f1 commit 5ec7a07
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/weather_where_you_are.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import geocoder
import requests

HTTP_STATUS_OK = 200
loc = geocoder.ip('me').json # Resolves location by IP
city_country = f"{loc['city']},{loc['country']}" # City string for URL
loc = geocoder.ip("me").json # Resolves location by IP
city_country = f"{loc['city']},{loc['country']}" # City string for URL
APPID = "beb97c1ce62559bba4e81e28de8be095"
weather = requests.get(f"http://api.openweathermap.org/data/2.5/weather?APPID={APPID}&q={city_country}").json()
weather = requests.get(
f"http://api.openweathermap.org/data/2.5/weather?APPID={APPID}&q={city_country}"
).json()
if weather.get("cod") == HTTP_STATUS_OK:
print(f"Weather in {city_country}\n------\n" + "\n".join(f"{key}: {value}" for key, value in weather.items()))
else: print("Error fetching data.")
print(
f"Weather in {city_country}\n------\n"
+ "\n".join(f"{key}: {value}" for key, value in weather.items())
)
else:
print("Error fetching data.")

0 comments on commit 5ec7a07

Please sign in to comment.