Spaces:
Sleeping
Sleeping
File size: 1,086 Bytes
8210d08 dd352c7 8210d08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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"]}!')
st.sidebar.image("assets/logo.png", use_column_width=True)
def get_login():
return st.session_state.get("login", {"status": False})
|