Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,14 +49,14 @@ def get_weather(city: str) -> str:
|
|
| 49 |
"units": "metric"
|
| 50 |
}
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
| 60 |
except Exception as e:
|
| 61 |
return f"Error fetching weather: {str(e)}"
|
| 62 |
|
|
|
|
| 49 |
"units": "metric"
|
| 50 |
}
|
| 51 |
|
| 52 |
+
response = requests.get(url, params=params)
|
| 53 |
|
| 54 |
+
data = response.json()
|
| 55 |
|
| 56 |
+
weather = data["weather"][0]["description"]
|
| 57 |
+
temp = data["main"]["temp"]
|
| 58 |
|
| 59 |
+
return f"The weather in{city} is {weather}, temperature {temp}°C"
|
| 60 |
except Exception as e:
|
| 61 |
return f"Error fetching weather: {str(e)}"
|
| 62 |
|