User-Profile-Management / backup.app.py
awacke1's picture
Create backup.app.py
7017f6b verified
import streamlit as st
@st.cache(suppress_st_warning=True,allow_output_mutation=True, ttl=86400) # 86400 seconds = 1 day
#@st.cache_data(ttl=86400) # 86400 seconds = 1 day
#@st.cache(suppress_st_warning=True, ttl=86400)
#@st.cache_data(experimental_allow_widgets=True) # πŸ‘ˆ Set the parameter
def cache_user_data():
return {'email': '', 'phone': '', 'password': ''}
#@st.cache_data(experimental_allow_widgets=True) # πŸ‘ˆ Set the parameter
def main():
st.title('User Data Caching Example')
# Retrieve or initialize cached data
cached_data = cache_user_data()
# Input fields with emojis
new_email = st.text_input("πŸ“§ Email Address", value=cached_data['email'])
new_phone = st.text_input("πŸ“± Mobile Phone", value=cached_data['phone'])
# Password field with an option to view contents
show_password = st.checkbox("Show password")
if show_password:
new_password = st.text_input("πŸ”‘ Password", value=cached_data['password'])
else:
new_password = st.text_input("πŸ”‘ Password", value=cached_data['password'], type='password')
# Update cache if data changes
if new_email != cached_data['email'] or new_phone != cached_data['phone'] or new_password != cached_data['password']:
cached_data['email'] = new_email
cached_data['phone'] = new_phone
cached_data['password'] = new_password
st.success("Data updated and cached!")
st.write("Cached Data:")
st.json(cached_data)
# Run the app
if __name__ == "__main__":
main()