Zekun Wu commited on
Commit
57fc3cd
·
1 Parent(s): 2a129bb
Files changed (1) hide show
  1. pages/2_batch_evaluation.py +11 -7
pages/2_batch_evaluation.py CHANGED
@@ -17,14 +17,17 @@ examples = {
17
 
18
  # Function to check password
19
  def check_password():
20
- password_input = st.sidebar.text_input("Enter Password:", type="password")
21
- submit_button = st.sidebar.button("Submit")
22
- if submit_button:
23
  if password_input == os.getenv('PASSWORD'):
24
- st.session_state['password_verified'] = True
25
- st.experimental_rerun()
26
  else:
27
- st.sidebar.error("Incorrect Password, please try again.")
 
 
 
 
 
 
28
 
29
  def batch_evaluate(uploaded_file):
30
  df = pd.read_csv(uploaded_file)
@@ -44,7 +47,8 @@ def batch_evaluate(uploaded_file):
44
  # Title of the application
45
  st.title('Natural Language Explanation Demo')
46
 
47
- if 'password_verified' not in st.session_state or not st.session_state['password_verified']:
 
48
  check_password()
49
  else:
50
  st.sidebar.success("Password Verified. Proceed with the demo.")
 
17
 
18
  # Function to check password
19
  def check_password():
20
+ def password_entered():
 
 
21
  if password_input == os.getenv('PASSWORD'):
22
+ st.session_state['password_correct'] = True
 
23
  else:
24
+ st.error("Incorrect Password, please try again.")
25
+
26
+ password_input = st.text_input("Enter Password:", type="password")
27
+ submit_button = st.button("Submit", on_click=password_entered)
28
+
29
+ if submit_button and not st.session_state.get('password_correct', False):
30
+ st.error("Please enter a valid password to access the demo.")
31
 
32
  def batch_evaluate(uploaded_file):
33
  df = pd.read_csv(uploaded_file)
 
47
  # Title of the application
48
  st.title('Natural Language Explanation Demo')
49
 
50
+ # Check if password has been validated
51
+ if not st.session_state.get('password_correct', False):
52
  check_password()
53
  else:
54
  st.sidebar.success("Password Verified. Proceed with the demo.")