Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| def login(): | |
| """ | |
| Display a login form and return True if login is successful, False otherwise. | |
| """ | |
| st.title("Login to Data Science Course App") | |
| #usernames | |
| usernames = ["admin", "student", "manxiii","zhu","WK","ruixi"] | |
| passwords = ["admin", "123", "manxi123","zhu123","WK123","ruixi123"] | |
| # Create a form for login | |
| with st.form("login_form"): | |
| username = st.text_input("Username") | |
| password = st.text_input("Password", type="password") | |
| submit_button = st.form_submit_button("Login") | |
| if submit_button: | |
| # Check credentials (test account) | |
| if username in usernames and password in passwords: | |
| # Store login state in session | |
| st.session_state.logged_in = True | |
| st.session_state.username = username | |
| st.success("Login successful!") | |
| st.rerun() | |
| else: | |
| st.error("Invalid username or password. Please try again.") | |
| return st.session_state.get("logged_in", False) |