Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,7 +41,12 @@ def factorial(n):
|
|
| 41 |
|
| 42 |
# callback to update query param on selectbox change
|
| 43 |
def update_params():
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
| 46 |
query_params = st.experimental_get_query_params()
|
| 47 |
# set selectbox value based on query param, or provide a default
|
|
@@ -57,13 +62,13 @@ selected_option = st.radio(
|
|
| 57 |
# set query param based on selection
|
| 58 |
st.experimental_set_query_params(option=selected_option)
|
| 59 |
|
| 60 |
-
|
| 61 |
try:
|
| 62 |
query_params = st.experimental_get_query_params()
|
| 63 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
| 64 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
| 65 |
except: # catch exception and set query param to predefined value
|
| 66 |
-
st.experimental_set_query_params(query="Genomics") #
|
| 67 |
query_params = st.experimental_get_query_params()
|
| 68 |
query_option = query_params['query'][0]
|
| 69 |
|
|
@@ -72,9 +77,11 @@ if 'query' not in st.session_state:
|
|
| 72 |
query = st.text_input("", value="artificial intelligence", key="query")
|
| 73 |
else:
|
| 74 |
query = st.text_input("", value=st.session_state["query"], key="query")
|
| 75 |
-
|
|
|
|
| 76 |
if 'query' not in st.session_state:
|
| 77 |
-
st.session_state.query = 'Genomics'
|
|
|
|
| 78 |
st.write(st.session_state.query)
|
| 79 |
|
| 80 |
|
|
|
|
| 41 |
|
| 42 |
# callback to update query param on selectbox change
|
| 43 |
def update_params():
|
| 44 |
+
try:
|
| 45 |
+
st.experimental_set_query_params(option=st.session_state.query)
|
| 46 |
+
except ValueError:
|
| 47 |
+
pass
|
| 48 |
+
|
| 49 |
+
# radio button options - plan is to hydrate when selected and change url along with textbox and search
|
| 50 |
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
| 51 |
query_params = st.experimental_get_query_params()
|
| 52 |
# set selectbox value based on query param, or provide a default
|
|
|
|
| 62 |
# set query param based on selection
|
| 63 |
st.experimental_set_query_params(option=selected_option)
|
| 64 |
|
| 65 |
+
# second set of controls, check the query params
|
| 66 |
try:
|
| 67 |
query_params = st.experimental_get_query_params()
|
| 68 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
| 69 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
| 70 |
except: # catch exception and set query param to predefined value
|
| 71 |
+
st.experimental_set_query_params(query="Genomics") # set default
|
| 72 |
query_params = st.experimental_get_query_params()
|
| 73 |
query_option = query_params['query'][0]
|
| 74 |
|
|
|
|
| 77 |
query = st.text_input("", value="artificial intelligence", key="query")
|
| 78 |
else:
|
| 79 |
query = st.text_input("", value=st.session_state["query"], key="query")
|
| 80 |
+
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
| 81 |
+
|
| 82 |
if 'query' not in st.session_state:
|
| 83 |
+
st.session_state.query = 'Genomics'
|
| 84 |
+
|
| 85 |
st.write(st.session_state.query)
|
| 86 |
|
| 87 |
|