Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,10 +39,11 @@ def get_weather(city: str) -> str:
|
|
| 39 |
Args:
|
| 40 |
city: A string representing a city
|
| 41 |
"""
|
| 42 |
-
url = f"https://
|
| 43 |
response = requests.get(url)
|
| 44 |
if response.status_code == 200:
|
| 45 |
-
|
|
|
|
| 46 |
else:
|
| 47 |
return "Error on fetching weather data."
|
| 48 |
|
|
|
|
| 39 |
Args:
|
| 40 |
city: A string representing a city
|
| 41 |
"""
|
| 42 |
+
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&units=metric" # In Celsius
|
| 43 |
response = requests.get(url)
|
| 44 |
if response.status_code == 200:
|
| 45 |
+
temperature = data['main']['temp']
|
| 46 |
+
return f"{temperature} °C"
|
| 47 |
else:
|
| 48 |
return "Error on fetching weather data."
|
| 49 |
|