import streamlit as st import os if "logged_in" not in st.session_state: st.session_state.logged_in = False def login(): with st.form("Login"): st.write("### Login") username = st.text_input("Username", type="default") password = st.text_input("Password", type="password") login = st.form_submit_button("Login") if login: # if username== st.secrets["auth"]["username"] and password == st.secrets["auth"]["password"]: if username== os.getenv("username") and password == os.getenv("password"): st.session_state.logged_in = True st.rerun() else: st.error("Incorrect username or password") def logout(): st.session_state.logged_in = False st.rerun() login_page = st.Page(login, title="Log in", icon=":material/login:") logout_page = st.Page(logout, title="Log out", icon=":material/logout:") Home = st.Page( "pages/Home.py", title="Home", icon=":material/home:" ) About = st.Page( "pages/About.py", title="About", icon=":material/info:" ) Dashboard = st.Page( "pages/Dashboard.py", title="Dashboard", icon=":material/dashboard:" ) Recommendation_System = st.Page( "pages/Recommendation System.py", title="Recommendation System", icon=":material/assistant_photo:", ) if st.session_state.logged_in: pg = st.navigation( { "": [Home, logout_page, About], "System" : [Dashboard, Recommendation_System] } ) else: pg = st.navigation([login_page]) pg.run()