Spaces:
Sleeping
Sleeping
Issue fixes
Browse files
app.py
CHANGED
@@ -44,6 +44,7 @@ def get_aqi(city:str, state:str, country:str)-> str:
|
|
44 |
"""
|
45 |
try:
|
46 |
IQAIR_API_KEY = os.environ["IQAIR_API_KEY"]
|
|
|
47 |
url = f"http://api.airvisual.com/v2/city?city={city}&state={state}&country={country}&key={IQAIR_API_KEY}"
|
48 |
payload={}
|
49 |
headers = {}
|
@@ -52,7 +53,7 @@ def get_aqi(city:str, state:str, country:str)-> str:
|
|
52 |
|
53 |
data_json = response.json()
|
54 |
if data_json["status"] == "success":
|
55 |
-
aqius = data_json["current"]["pollution"]["aqius"]
|
56 |
return f"The current air quality in {city} is {aqius}."
|
57 |
else:
|
58 |
return "No air quality data was fetched.";
|
|
|
44 |
"""
|
45 |
try:
|
46 |
IQAIR_API_KEY = os.environ["IQAIR_API_KEY"]
|
47 |
+
# http://api.airvisual.com/v2/city?city=Chengdu&state=Sichuan&country=China&key=2cb6f85b-18f2-453d-a0c4-f060dae8b92c
|
48 |
url = f"http://api.airvisual.com/v2/city?city={city}&state={state}&country={country}&key={IQAIR_API_KEY}"
|
49 |
payload={}
|
50 |
headers = {}
|
|
|
53 |
|
54 |
data_json = response.json()
|
55 |
if data_json["status"] == "success":
|
56 |
+
aqius = data_json["data"]["current"]["pollution"]["aqius"]
|
57 |
return f"The current air quality in {city} is {aqius}."
|
58 |
else:
|
59 |
return "No air quality data was fetched.";
|