Skip to content

Instantly share code, notes, and snippets.

@tvst
Created June 11, 2020 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvst/7b845b7988acc505c387c0c7d1532ab7 to your computer and use it in GitHub Desktop.
Save tvst/7b845b7988acc505c387c0c7d1532ab7 to your computer and use it in GitHub Desktop.
import streamlit as st
# Grab SessionState.py from here:
# https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92
# (This is a temporary solution until we provide an official API for this)
import SessionState
DEFAULT_FOO = ""
DEFAULT_BAR = ""
state = SessionState.get(foo=DEFAULT_FOO, bar=DEFAULT_BAR)
current_foo = st.text_input("Foo", DEFAULT_FOO)
current_bar = st.text_input("Bar", DEFAULT_BAR)
if st.button("Submit"):
state.foo = current_foo
state.bar = current_bar
st.write("Submitted foo = ", state.foo)
st.write("Submitted bar = ", state.bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment