Zekun Wu commited on
Commit
5485067
1 Parent(s): 8766924
Files changed (1) hide show
  1. pages/2_batch_evaluation.py +13 -10
pages/2_batch_evaluation.py CHANGED
@@ -5,15 +5,18 @@ import os
5
 
6
 
7
  def check_password():
8
- with st.sidebar:
9
- password_input = st.text_input("Enter Password:", type="password")
10
- submit_button = st.button("Submit")
11
- if submit_button:
12
- if password_input == os.getenv('PASSWORD'):
13
- st.session_state['password_verified'] = True
14
- st.experimental_rerun()
15
- else:
16
- st.error("Incorrect Password, please try again.")
 
 
 
17
 
18
 
19
  def batch_evaluate(uploaded_file):
@@ -44,7 +47,7 @@ def batch_evaluate(uploaded_file):
44
 
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.")
 
5
 
6
 
7
  def check_password():
8
+ def password_entered():
9
+ if password_input == os.getenv('PASSWORD'):
10
+ st.session_state['password_correct'] = True
11
+ else:
12
+ st.error("Incorrect Password, please try again.")
13
+
14
+ password_input = st.text_input("Enter Password:", type="password")
15
+ submit_button = st.button("Submit", on_click=password_entered)
16
+
17
+ if submit_button and not st.session_state.get('password_correct', False):
18
+ st.error("Please enter a valid password to access the demo.")
19
+
20
 
21
 
22
  def batch_evaluate(uploaded_file):
 
47
 
48
  st.title('Natural Language Explanation Demo')
49
 
50
+ if not st.session_state.get('password_correct', False):
51
  check_password()
52
  else:
53
  st.sidebar.success("Password Verified. Proceed with the demo.")