Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1000,7 +1000,18 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 1000 |
}
|
| 1001 |
response = requests.get('https://api.openweathermap.org/data/2.5/weather', params=params)
|
| 1002 |
if response.status_code == 200:
|
| 1003 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1004 |
else:
|
| 1005 |
return None
|
| 1006 |
|
|
|
|
| 1000 |
}
|
| 1001 |
response = requests.get('https://api.openweathermap.org/data/2.5/weather', params=params)
|
| 1002 |
if response.status_code == 200:
|
| 1003 |
+
temperature = weather_data.get('main', {}).get('temp', 'TEMP_FROM_THE_JSON')
|
| 1004 |
+
forecast = [item.get('description', '') for item in weather_data.get('weather', [])]
|
| 1005 |
+
|
| 1006 |
+
new_json = {
|
| 1007 |
+
"location": location,
|
| 1008 |
+
"temperature": temperature,
|
| 1009 |
+
"unit": unit,
|
| 1010 |
+
"forecast": forecast
|
| 1011 |
+
}
|
| 1012 |
+
|
| 1013 |
+
return json.dumps(new_json, indent=2)
|
| 1014 |
+
|
| 1015 |
else:
|
| 1016 |
return None
|
| 1017 |
|