generated from giswqs/streamlit-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamlit_app.py
51 lines (40 loc) · 1.64 KB
/
streamlit_app.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
import streamlit as st
from streamlit_option_menu import option_menu
from apps import home, heatmap, upload # import your app modules here
st.set_page_config(page_title="Streamlit Geospatial", layout="wide")
# A dictionary of apps in the format of {"App title": "App icon"}
# More icons can be found here: https://icons.getbootstrap.com
apps = [
{"func": home.app, "title": "Home", "icon": "house"},
{"func": heatmap.app, "title": "Heatmap", "icon": "map"},
{"func": upload.app, "title": "Upload", "icon": "cloud-upload"},
]
titles = [app["title"] for app in apps]
titles_lower = [title.lower() for title in titles]
icons = [app["icon"] for app in apps]
params = st.experimental_get_query_params()
if "page" in params:
default_index = int(titles_lower.index(params["page"][0].lower()))
else:
default_index = 0
with st.sidebar:
selected = option_menu(
"Main Menu",
options=titles,
icons=icons,
menu_icon="cast",
default_index=default_index,
)
st.sidebar.title("About")
st.sidebar.info(
"""
This web [app](https://share.streamlit.io/giswqs/streamlit-template) is maintained by [Qiusheng Wu](https://wetlands.io). You can follow me on social media:
[GitHub](https://github.com/giswqs) | [Twitter](https://twitter.com/giswqs) | [YouTube](https://www.youtube.com/c/QiushengWu) | [LinkedIn](https://www.linkedin.com/in/qiushengwu).
Source code: <https://github.com/giswqs/streamlit-template>
More menu icons: <https://icons.getbootstrap.com>
"""
)
for app in apps:
if app["title"] == selected:
app["func"]()
break