wop commited on
Commit
1093cd0
1 Parent(s): 1897897

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -20,18 +20,20 @@ icon("⚡")
20
 
21
  st.subheader("Chatbot", divider="rainbow", anchor=False)
22
 
23
-
24
  # LOGIN
25
  password = os.environ['PASSWORD']
26
 
27
- # Create a login form
28
- username = st.text_input("Username")
29
- password_input = st.text_input("Password", type="password")
 
 
 
30
 
31
- # Authenticate user
32
- if st.button("Login"):
33
- if username == "admin" and password_input == password:
34
  st.session_state.authenticated = True
 
35
  else:
36
  st.error("Invalid username or password")
37
 
@@ -39,7 +41,6 @@ if st.button("Login"):
39
  if "authenticated" not in st.session_state or not st.session_state.authenticated:
40
  st.stop() # Stop the app from running if the user is not authenticated
41
 
42
-
43
  client = Groq(
44
  api_key=os.environ['GROQ_API_KEY'],
45
  )
 
20
 
21
  st.subheader("Chatbot", divider="rainbow", anchor=False)
22
 
 
23
  # LOGIN
24
  password = os.environ['PASSWORD']
25
 
26
+ # Create a login form container
27
+ login_container = st.container()
28
+
29
+ with login_container:
30
+ password_input = st.text_input("Password", type="password")
31
+ st.button("authenticate", on_click=login, args=(password_input))
32
 
33
+ def login(username, password_input):
34
+ if password_input == password:
 
35
  st.session_state.authenticated = True
36
+ login_container.empty() # Clear the login form container
37
  else:
38
  st.error("Invalid username or password")
39
 
 
41
  if "authenticated" not in st.session_state or not st.session_state.authenticated:
42
  st.stop() # Stop the app from running if the user is not authenticated
43
 
 
44
  client = Groq(
45
  api_key=os.environ['GROQ_API_KEY'],
46
  )