Spaces:
Runtime error
Runtime error
Create pages/login.py
Browse files- pages/login.py +34 -0
pages/login.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pages/login.py
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
def show_login_page(auth_manager):
|
| 6 |
+
"""Display login page"""
|
| 7 |
+
st.title("🔒 Login to Stock Chart Assistant")
|
| 8 |
+
|
| 9 |
+
with st.form("login_form"):
|
| 10 |
+
username = st.text_input("Username").lower()
|
| 11 |
+
password = st.text_input("Password", type="password")
|
| 12 |
+
submit = st.form_submit_button("Login")
|
| 13 |
+
|
| 14 |
+
if submit:
|
| 15 |
+
if auth_manager.login(username, password):
|
| 16 |
+
st.success("Login successful!")
|
| 17 |
+
st.rerun() # Rerun to update the page
|
| 18 |
+
else:
|
| 19 |
+
st.error("Invalid username or password!")
|
| 20 |
+
|
| 21 |
+
# Show demo credentials
|
| 22 |
+
st.markdown("---")
|
| 23 |
+
st.markdown("### Demo Access")
|
| 24 |
+
st.info("""
|
| 25 |
+
Use these credentials to try the demo:
|
| 26 |
+
- Username: synaptyx
|
| 27 |
+
- Password: demo
|
| 28 |
+
""")
|
| 29 |
+
|
| 30 |
+
def show_logout_button(auth_manager):
|
| 31 |
+
"""Display logout button"""
|
| 32 |
+
if st.sidebar.button("Logout"):
|
| 33 |
+
auth_manager.logout()
|
| 34 |
+
st.rerun() # Rerun to update the page
|