awacke1 commited on
Commit
f630872
Β·
verified Β·
1 Parent(s): 06454e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from datetime import timedelta
3
+
4
+ # Function to cache user data
5
+ @st.cache_resource(ttl=timedelta(days=1), max_entries=10, show_spinner=True)
6
+ def cache_user_data(email, phone, password):
7
+ return {'email': email, 'phone': phone, 'password': password}
8
+
9
+ # Main app function
10
+ def main():
11
+ st.title('User Data Caching Example')
12
+
13
+ # Retrieve cached data if it exists
14
+ cached_data = cache_user_data("", "", "")
15
+ email, phone, password = cached_data['email'], cached_data['phone'], cached_data['password']
16
+
17
+ # Input fields with emojis
18
+ new_email = st.text_input("πŸ“§ Email Address", value=email)
19
+ new_phone = st.text_input("πŸ“± Mobile Phone", value=phone)
20
+ new_password = st.text_input("πŸ”‘ Password", value=password, type='password')
21
+
22
+ # Update cache if data changes
23
+ if new_email != email or new_phone != phone or new_password != password:
24
+ cache_user_data(new_email, new_phone, new_password)
25
+ st.success("Data updated and cached!")
26
+
27
+ st.write("Cached Data:")
28
+ st.json(cached_data)
29
+
30
+ # Run the app
31
+ if __name__ == "__main__":
32
+ main()