Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import os | |
| def initialize_login(): | |
| if "login" not in st.session_state: | |
| st.columns(3)[1].image("assets/logo.png") | |
| username = st.text_input("Username") | |
| password = st.text_input("Password", type="password") | |
| if st.button("Login"): | |
| # TODO: replace with actual authorization check | |
| authorized = {"status": True, "Name": "John Doe", "username": "johndoe"} | |
| if authorized["status"]: | |
| st.session_state["login"] = authorized | |
| os.makedirs( | |
| os.path.join(".sessions", st.session_state["login"]["username"]), | |
| exist_ok=True, | |
| ) | |
| st.success("Login Successful!") | |
| st.experimental_rerun() | |
| else: | |
| st.error("Invalid username or password") | |
| else: | |
| st.sidebar.success(f'Hello, {st.session_state["login"]["Name"]}!') | |
| def get_login(): | |
| return st.session_state.get("login", {"status": False}) | |