khaled06 commited on
Commit
fb380d1
·
verified ·
1 Parent(s): 164f99b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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 = http://api.weatherstack.com/current
45
- ? access_key = ff33163dc424d6430b66535cb02dda7d
46
- & query = city
47
  data = response.json()
48
 
49
- temp = data['current']['weather_descriptions']
50
- retrun f"the current weather in {city} is {temp}"
 
 
 
 
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