Spaces:
Sleeping
Sleeping
import streamlit as st | |
from datetime import timedelta | |
# Function to cache user data | |
def cache_user_data(email, phone, password): | |
return {'email': email, 'phone': phone, 'password': password} | |
# Main app function | |
def main(): | |
st.title('User Data Caching Example') | |
# Retrieve cached data if it exists | |
cached_data = cache_user_data("", "", "") | |
email, phone, password = cached_data['email'], cached_data['phone'], cached_data['password'] | |
# Input fields with emojis | |
new_email = st.text_input("π§ Email Address", value=email) | |
new_phone = st.text_input("π± Mobile Phone", value=phone) | |
new_password = st.text_input("π Password", value=password, type='password') | |
# Update cache if data changes | |
if new_email != email or new_phone != phone or new_password != password: | |
cache_user_data(new_email, new_phone, new_password) | |
st.success("Data updated and cached!") | |
st.write("Cached Data:") | |
st.json(cached_data) | |
# Run the app | |
if __name__ == "__main__": | |
main() | |