streamlit / app.py
SUNGJIN LEE
Time Window ์ถ”๊ฐ€
7f4ef9c
import streamlit as st
import os
if "logged_in" not in st.session_state:
st.session_state.logged_in = False
def login():
st.write("# SKT AI Fellowship Team ASAP ๐Ÿ‘‹")
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("Username ๋˜๋Š” Password๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
def logout():
st.session_state.logged_in = False
st.rerun()
login_page = st.Page(login, title="Login", icon=":material/login:")
logout_page = st.Page(logout, title="Logout", 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:"
)
Data = st.Page(
"Pages/Data.py",
title="Data",
icon=":material/data_usage:"
)
Algorithm = st.Page(
"Pages/Algorithm.py",
title="Algorithm",
icon=":material/insights:"
)
Dashboard = st.Page(
"Pages/Dashboard.py",
title="Dashboard",
icon=":material/dashboard:"
)
Recommendation_By_Time = st.Page(
"Pages/Recommendation_By_Time.py",
title="Recommendation By Time",
icon=":material/schedule:"
)
Time_Window_Recommendation = st.Page(
"Pages/Time_Window_Recommendation.py",
title="Time Window Recommendation",
icon=":material/calendar_view_day:"
)
if st.session_state.logged_in:
pg = st.navigation(
{
"": [Home, About],
# "Development": [Data, Algorithm],
"System" : [Dashboard, Recommendation_By_Time, Time_Window_Recommendation],
"Account": [logout_page]
}
)
else:
pg = st.navigation([login_page])
pg.run()