Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,20 @@
|
|
1 |
-
import os
|
2 |
import streamlit as st
|
3 |
-
from streamlit_cookies_manager import EncryptedCookieManager
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
# This way you can run your app on Streamlit Cloud without cookie name clashes with other apps.
|
9 |
-
prefix="ktosiek/streamlit-cookies-manager/",
|
10 |
-
# You should really setup a long COOKIES_PASSWORD secret if you're running on Streamlit Cloud.
|
11 |
-
password=os.environ.get("COOKIES_PASSWORD", "My secret password"),
|
12 |
-
)
|
13 |
-
if not cookies.ready():
|
14 |
-
# Wait for the component to load and send us current cookies.
|
15 |
-
st.stop()
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
+
# Input fields
|
4 |
+
a = st.number_input("First value", 1, 1000)
|
5 |
+
b = st.number_input("Second value", 1, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# Perform an operation, and save its result
|
8 |
+
if st.button("Compute value"):
|
9 |
+
result = a * b
|
10 |
+
st.experimental_set_query_params(my_saved_result=result) # Save value
|
11 |
+
|
12 |
+
# Retrieve app state
|
13 |
+
app_state = st.experimental_get_query_params()
|
14 |
+
|
15 |
+
# Display saved result if it exist
|
16 |
+
if "my_saved_result" in app_state:
|
17 |
+
saved_result = app_state["my_saved_result"][0]
|
18 |
+
st.write("Here is your result", saved_result)
|
19 |
+
else:
|
20 |
+
st.write("No result to display, compute a value first.")
|