Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,40 +23,42 @@ with st.form(key='my form'):
|
|
23 |
# province = province,
|
24 |
# ))
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
md_head = '''| ID | City |Province | US AQI |
|
36 |
| -------- | -------- | -------- | -------- |
|
37 |
'''
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
| -------- | -------- | -------- | -------- |
|
54 |
'''
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
|
62 |
|
|
|
23 |
# province = province,
|
24 |
# ))
|
25 |
|
26 |
+
if submit:
|
27 |
+
st.markdown(f'''You entered:
|
28 |
+
Country: `{country}`,
|
29 |
+
Province:`{province}`
|
30 |
+
''')
|
31 |
|
32 |
+
if country != '':
|
33 |
+
# all provinces
|
34 |
+
if province == '':
|
35 |
+
md_head = '''| ID | City |Province | US AQI |
|
|
|
36 |
| -------- | -------- | -------- | -------- |
|
37 |
'''
|
38 |
+
md = st.empty()
|
39 |
+
generator = AirQualityQuery.air_quality_by_country(country, return_frequency=10)
|
40 |
+
while True:
|
41 |
+
try:
|
42 |
+
with st.spinner():
|
43 |
+
i = next(generator)
|
44 |
+
new_md = ''
|
45 |
+
for id, j in enumerate(i):
|
46 |
+
new_md += f'''|{id + 1}|{j[0]}|{j[1]}|{j[2]}|\n'''
|
47 |
+
md.markdown(md_head + new_md)
|
48 |
+
except StopIteration:
|
49 |
+
break
|
50 |
+
# specific province
|
51 |
+
else:
|
52 |
+
md_head = '''| ID | City |Province | US AQI |
|
53 |
| -------- | -------- | -------- | -------- |
|
54 |
'''
|
55 |
+
md = st.empty()
|
56 |
+
i = AirQualityQuery.air_quality_by_province_country(country, province)
|
57 |
+
new_md = ''
|
58 |
+
for id, j in enumerate(i):
|
59 |
+
new_md += f'''|{id + 1}|{j[0]}|{j[1]}|{j[2]}|\n'''
|
60 |
+
md.markdown(md_head + new_md)
|
61 |
+
|
62 |
+
|
63 |
|
64 |
|