Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,20 +23,25 @@ st.subheader("Chatbot", divider="rainbow", anchor=False)
|
|
| 23 |
# LOGIN
|
| 24 |
password = os.environ['PASSWORD']
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
def login(password_input):
|
| 27 |
if password_input == password:
|
| 28 |
st.session_state.authenticated = True
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
#
|
| 36 |
if "authenticated" not in st.session_state or not st.session_state.authenticated:
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
client = Groq(
|
| 42 |
api_key=os.environ['GROQ_API_KEY'],
|
|
|
|
| 23 |
# LOGIN
|
| 24 |
password = os.environ['PASSWORD']
|
| 25 |
|
| 26 |
+
# Create a login form container
|
| 27 |
+
login_container = st.container()
|
| 28 |
+
|
| 29 |
def login(password_input):
|
| 30 |
if password_input == password:
|
| 31 |
st.session_state.authenticated = True
|
| 32 |
+
login_container.empty() # Clear the login form container
|
| 33 |
+
else:
|
| 34 |
+
st.error("Invalid password")
|
| 35 |
|
| 36 |
+
with login_container:
|
| 37 |
+
password_input = st.text_input("Password", type="password")
|
| 38 |
+
st.button("authenticate", on_click=login(password_input))
|
| 39 |
|
| 40 |
+
# Only allow access to the app if the user is authenticated
|
| 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 |
+
else:
|
| 44 |
+
login_container.empty()
|
| 45 |
|
| 46 |
client = Groq(
|
| 47 |
api_key=os.environ['GROQ_API_KEY'],
|