Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from state import provide_state
|
3 |
+
import json
|
4 |
+
|
5 |
+
INITIAL_CONF = {
|
6 |
+
"checkbox": False,
|
7 |
+
"number": 0.0
|
8 |
+
}
|
9 |
+
|
10 |
+
@provide_state
|
11 |
+
def main(state):
|
12 |
+
query_params = st.experimental_get_query_params()
|
13 |
+
if "conf" in query_params:
|
14 |
+
state.conf = json.loads(query_params["conf"][0])
|
15 |
+
state.conf = state.conf or INITIAL_CONF
|
16 |
+
|
17 |
+
state.conf["checkbox"] = st.checkbox("Retain State !", value=state.conf["checkbox"])
|
18 |
+
state.conf["number"] = st.number_input("You Too Retain State !", value=state.conf["number"])
|
19 |
+
st.experimental_set_query_params(**{"conf": json.dumps(state.conf)})
|
20 |
+
|
21 |
+
main()
|