Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -76,8 +76,16 @@ def get_weather_by_city(city_name: str) -> str:
|
|
| 76 |
weather_response = requests.get(weather_url)
|
| 77 |
weather_response.raise_for_status()
|
| 78 |
weather_data = weather_response.json()
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
except requests.RequestException as e:
|
| 83 |
return f"Ошибка запроса погоды: {str(e)}"
|
|
|
|
| 76 |
weather_response = requests.get(weather_url)
|
| 77 |
weather_response.raise_for_status()
|
| 78 |
weather_data = weather_response.json()
|
| 79 |
+
|
| 80 |
+
current = weather_data["current_weather"]
|
| 81 |
+
return (
|
| 82 |
+
f"Погода в {city_name}:\n"
|
| 83 |
+
f"• Температура: {current['temperature']}°C\n"
|
| 84 |
+
f"• Скорость ветра: {current['windspeed']} км/ч\n"
|
| 85 |
+
f"• Направление ветра: {current['winddirection']}°\n"
|
| 86 |
+
f"• Погодный код: {current['weathercode']}\n"
|
| 87 |
+
f"• Время измерения: {current['time'][-5:]}"
|
| 88 |
+
)
|
| 89 |
|
| 90 |
except requests.RequestException as e:
|
| 91 |
return f"Ошибка запроса погоды: {str(e)}"
|