awacke1 commited on
Commit
613e418
Β·
verified Β·
1 Parent(s): f630872

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,7 +3,7 @@ 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
@@ -11,13 +11,19 @@ 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:
@@ -29,4 +35,4 @@ def main():
29
 
30
  # Run the app
31
  if __name__ == "__main__":
32
- main()
 
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
 
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
+
21
+ # Password field with an option to view contents
22
+ password_placeholder = st.empty()
23
+ if st.checkbox("Show password"):
24
+ new_password = password_placeholder.text_input("πŸ”‘ Password", value=password)
25
+ else:
26
+ new_password = password_placeholder.text_input("πŸ”‘ Password", value=password, type='password')
27
 
28
  # Update cache if data changes
29
  if new_email != email or new_phone != phone or new_password != password:
 
35
 
36
  # Run the app
37
  if __name__ == "__main__":
38
+ main()