Thanks this helped a lot. It worked.
Thanks for the help. But I still cannot figure it out. Can you provide code for any sample multipage app with the login feature, if possible? @blackary @rafikul-m @NELSON_JOSEPH
Here’s one way to accomplish that @Anandhu_H
import streamlit as st
from st_pages import show_pages, Page, hide_pages
show_pages(
[
Page("streamlit_app.py", "Home", icon="🏠"),
Page("secret_page.py", "After Login", icon="🔒"),
]
)
if "logged_in" not in st.session_state:
st.session_state.logged_in = False
def log_in():
username = st.session_state.username
if username == "test":
st.session_state.logged_in = True
else:
st.write("Invalid username")
def log_out():
st.session_state.logged_in = False
if not st.session_state.logged_in:
hide_pages(["After Login"])
st.text_input("Username (use 'test')", key="username", on_change=log_in)
else:
st.button("Log out", on_click=log_out)
1 Like
You can check this repository. It’s a fully working application with a login landing page and multiple pages within it that can be accessed from the left slide bar. GitHub Repository
1 Like