Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,15 +39,17 @@ def get_weather_api(city : str) -> str:
|
|
39 |
Args:
|
40 |
city: A string that repesents a city name
|
41 |
"""
|
42 |
-
api_key = ff33163dc424d6430b66535cb02dda7d
|
43 |
|
44 |
-
response =
|
45 |
-
? access_key = ff33163dc424d6430b66535cb02dda7d
|
46 |
-
& query = city
|
47 |
data = response.json()
|
48 |
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
|
|
|
39 |
Args:
|
40 |
city: A string that repesents a city name
|
41 |
"""
|
42 |
+
api_key = 'ff33163dc424d6430b66535cb02dda7d'
|
43 |
|
44 |
+
response = requests.get(url)
|
|
|
|
|
45 |
data = response.json()
|
46 |
|
47 |
+
if 'current' in data and 'weather_descriptions' in data['current']:
|
48 |
+
temp = data['current']['weather_descriptions'][0]
|
49 |
+
return f"The current weather in {city} is {temp}."
|
50 |
+
else:
|
51 |
+
return f"Could not retrieve weather data for {city}."
|
52 |
+
|
53 |
|
54 |
|
55 |
|