Adapting commited on
Commit
45a4f17
·
1 Parent(s): 5655ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -30
app.py CHANGED
@@ -23,40 +23,42 @@ with st.form(key='my form'):
23
  # province = province,
24
  # ))
25
 
26
- st.markdown(f'''You entered:
27
- Country: `{country}`,
28
- Province:`{province}`
29
- ''')
 
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
 
 
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