weather.py
Browse files- utils/weather.py +12 -0
utils/weather.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
from config import WEATHER_API_KEY
|
3 |
+
|
4 |
+
def get_weather():
|
5 |
+
url = f"http://api.weatherapi.com/v1/current.json?key={WEATHER_API_KEY}&q=Black Rock Desert"
|
6 |
+
response = requests.get(url)
|
7 |
+
if response.status_code == 200:
|
8 |
+
data = response.json()
|
9 |
+
weather_info = f"Current temperature: {data['current']['temp_c']}°C\nCondition: {data['current']['condition']['text']}\nWind: {data['current']['wind_kph']} kph"
|
10 |
+
return weather_info
|
11 |
+
else:
|
12 |
+
return "Unable to fetch weather information at the moment."
|