import streamlit as st # Set the page configuration st.set_page_config(layout="wide") st.title("Main App Here - Demo for Navigation Pages") if "logged_in" not in st.session_state: st.session_state.logged_in = False if "username" not in st.session_state: st.session_state.username = "" if "password" not in st.session_state: st.session_state.password = "" def login(): st.session_state.username = st.text_input("Username") st.session_state.password = st.text_input("Password", type="password") if st.button("Log in"): if st.session_state.username == "abc" and st.session_state.password == "123": st.session_state.logged_in = True st.experimental_rerun() else: st.error("Incorrect username or password") def logout(): if st.button("Log out"): st.session_state.logged_in = False st.experimental_rerun() login_page = st.Page(login, title="Log in", icon=":material/login:") logout_page = st.Page(logout, title="Log out", icon=":material/logout:") dashboard = st.Page( "reports/dashboard.py", title="Dashboard", icon=":material/dashboard:", default=True ) bugs = st.Page("reports/bugs.py", title="Bug reports", icon=":material/bug_report:") alerts = st.Page( "reports/alerts.py", title="System alerts", icon=":material/notification_important:" ) search = st.Page("tools/search.py", title="Search", icon=":material/search:") history = st.Page("tools/history.py", title="History", icon=":material/history:") configure = st.Page("tools/configure.py", title="Configure", icon=":material/settings:") if st.session_state.logged_in: pg = st.navigation( { "Account": [logout_page], "Reports": [dashboard, bugs, alerts], "Tools": [search, history, configure], } ) else: pg = st.navigation([login_page]) pg.run()