Created
June 17, 2022 06:18
-
-
Save knowsuchagency/ac4c0accea940264b7091c89e80779fb to your computer and use it in GitHub Desktop.
streamlit login form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
def login_form(): | |
if not ("username" in st.session_state and "password" in st.session_state): | |
st.write("## Login") | |
with st.form("Login"): | |
username = st.text_input("Username") | |
password = st.text_input("Password") | |
submitted = st.form_submit_button("Submit") | |
if submitted: | |
st.session_state.username = username | |
st.session_state.password = password | |
st.experimental_rerun() | |
else: | |
st.stop() | |
def logout_form(): | |
def inner(): | |
del st.session_state.username | |
del st.session_state.password | |
st.button("# Logout", on_click=inner) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
don't use this script as it is; it's just example code