-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.py
56 lines (41 loc) · 1.3 KB
/
Home.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import streamlit as st
from streamlit_option_menu import option_menu
import httpx
st.set_page_config(
initial_sidebar_state="collapsed"
)
def query_ui():
filters = {
"日間": "day",
"週間": "week",
"月間": "month",
"四半期": "3month",
"年間": "year",
"総合": "total",
}
filter = st.selectbox('',(list(filters.keys())))
st.write('')
return filters, filter
def main():
changed = option_menu(None, ["Home", "Search"],
icons=['house', 'search'],
orientation="horizontal",
default_index=0)
if changed == "Search":
st.switch_page('pages/Search.py')
st.markdown('## ハーメルンランキング')
filters, filter= query_ui()
if st.button("データ取得"):
with httpx.Client(timeout=httpx.Timeout(None)) as client:
response = client.get(f'https://hameln-api.onrender.com/ranking/?filter={filters[filter]}')
res = response.json()
st.write('')
st.code("""
curl -X \'GET\' \\
\'https://hameln-api.onrender.com/ranking/?filter={}' \\
-H \'accept: application/json\'
""".format(filters[filter]))
st.write('')
st.json(res)
if __name__ == '__main__':
main()