Hi,
you may find this library interesting:
I don’t know if this could be what you are looking for.
page: feed.py
import streamlit as st
def show_feed_page(user_id):
st.subheader("Test")
st.write(f"User ID: {user_id}")
page: home.py
import streamlit as st
def show_home_page():
st.title("Home Page")
st.write("This is the home page content.")
app.py
import streamlit as st
from pages.home import show_home_page
from pages.feed import show_feed_page
# Mock database
class MockDatabase:
users = {"1234": {"name": "David Oden", "email": "doden@xxxxx.com"}}
@staticmethod
def check_user_exists(user_id):
return user_id in MockDatabase.users
if "page" not in st.session_state:
st.session_state.page = "home"
if "userid" not in st.session_state:
st.session_state.userid = ""
def login_action(id):
user_exists = MockDatabase.check_user_exists(id)
if user_exists:
st.success(f"Login successful! Welcome, {MockDatabase.users[id]['name']}!")
st.session_state.page = "feed" # Go to the next page
st.session_state.userid = id
else:
st.error("User not found. Please check your ID.")
with st.form(key="login_form"):
id_input = st.text_input("User ID", type="password", placeholder="4 digit pin (1234)")
login_button = st.form_submit_button("Login")
# Check if the form is submitted
if login_button:
login_action(id_input)
# Render content based on the current page
if st.session_state.page == "home":
if st.button("Go to Feed Page"):
st.session_state.page = "feed"
show_home_page()
elif st.session_state.page == "feed":
if st.button("Go back to Home Page"):
st.session_state.page = "home"
show_feed_page(st.session_state.userid)