generated from BESSER-PEARL/template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
45 lines (40 loc) · 1.41 KB
/
main.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
import sys
import streamlit as st
from streamlit.web import cli as stcli
from src.app.app import create_app
from src.ui.admin import admin
from src.ui.playground import playground
from src.ui.about import about
from src.utils.session_monitoring import run_thread_session_monitoring
from src.ui.settings import settings
from src.ui.sidebar import sidebar_menu
from src.utils.utils import disable_input_focusout, remove_header, remove_top_margin, set_screen_data_component
st.set_page_config(layout="wide")
if __name__ == "__main__":
if st.runtime.exists():
# Create the app, only 1 time, shared across sessions
create_app()
# Run session monitoring in another thread, only 1 time
run_thread_session_monitoring()
# Show menu in sidebar
with st.sidebar:
page = sidebar_menu()
# Remove top margin
remove_top_margin(page)
# Remove Streamlit's header
remove_header()
# Display a page
if page == 'Playground':
# Used to get screen info, e.g., the height and width
set_screen_data_component()
playground()
elif page == 'Admin':
admin()
elif page == 'Settings':
settings()
elif page == 'About DataBot':
about()
disable_input_focusout()
else:
sys.argv = ["streamlit", "run", sys.argv[0]]
sys.exit(stcli.main())