Spaces:
Sleeping
Sleeping
File size: 704 Bytes
8c881ff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import streamlit as st
# Initialize session state
if 'username' not in st.session_state:
st.session_state.username = ''
if 'scratch_pad' not in st.session_state:
st.session_state.scratch_pad = ''
def save_session():
st.session_state.username = username
st.session_state.scratch_pad = scratch_pad
st.title("Welcome to My App")
if st.session_state.username:
st.subheader(f"Welcome back, {st.session_state.username}!")
scratch_pad = st.text_area("Scratch Pad", value=st.session_state.scratch_pad, height=200)
if st.button("💾 Save"):
save_session()
else:
username = st.text_input("Please enter your name:")
if st.button("🔑 Login"):
save_session() |