Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,25 +46,8 @@ def update_params():
|
|
| 46 |
#st.experimental_set_query_params(option=st.session_state.query)
|
| 47 |
#except ValueError:
|
| 48 |
# pass
|
| 49 |
-
|
| 50 |
-
# radio button options - plan is to hydrate when selected and change url along with textbox and search
|
| 51 |
-
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
| 52 |
-
query_params = st.experimental_get_query_params()
|
| 53 |
-
# set selectbox value based on query param, or provide a default
|
| 54 |
-
ix = 0
|
| 55 |
-
if query_params:
|
| 56 |
-
try:
|
| 57 |
-
q0 = query_params['query'][0]
|
| 58 |
-
ix = options.index(q0)
|
| 59 |
-
except ValueError:
|
| 60 |
-
pass
|
| 61 |
-
selected_option = st.radio(
|
| 62 |
-
"Param", options, index=ix, key="query", on_change=update_params
|
| 63 |
-
)
|
| 64 |
-
# set query param based on selection
|
| 65 |
-
st.experimental_set_query_params(option=selected_option)
|
| 66 |
|
| 67 |
-
#
|
| 68 |
try:
|
| 69 |
query_params = st.experimental_get_query_params()
|
| 70 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
|
@@ -73,8 +56,6 @@ except: # catch exception and set query param to predefined value
|
|
| 73 |
st.experimental_set_query_params(query="Genomics") # set default
|
| 74 |
query_params = st.experimental_get_query_params()
|
| 75 |
query_option = query_params['query'][0]
|
| 76 |
-
|
| 77 |
-
# set the text input to query value if in session
|
| 78 |
if 'query' not in st.session_state:
|
| 79 |
#st.session_state['query'] = 'value'
|
| 80 |
query = st.text_input("", value="artificial intelligence", key="query")
|
|
@@ -84,12 +65,27 @@ try:
|
|
| 84 |
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
| 85 |
except: # catch exception and set query param to predefined value
|
| 86 |
print("Error cant set after init")
|
| 87 |
-
|
| 88 |
if 'query' not in st.session_state:
|
| 89 |
st.session_state.query = 'Genomics'
|
| 90 |
-
|
| 91 |
st.write(st.session_state.query)
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
|
|
|
|
| 46 |
#st.experimental_set_query_params(option=st.session_state.query)
|
| 47 |
#except ValueError:
|
| 48 |
# pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
# Text Input, check the query params set the text input to query value if in session
|
| 51 |
try:
|
| 52 |
query_params = st.experimental_get_query_params()
|
| 53 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
|
|
|
| 56 |
st.experimental_set_query_params(query="Genomics") # set default
|
| 57 |
query_params = st.experimental_get_query_params()
|
| 58 |
query_option = query_params['query'][0]
|
|
|
|
|
|
|
| 59 |
if 'query' not in st.session_state:
|
| 60 |
#st.session_state['query'] = 'value'
|
| 61 |
query = st.text_input("", value="artificial intelligence", key="query")
|
|
|
|
| 65 |
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
| 66 |
except: # catch exception and set query param to predefined value
|
| 67 |
print("Error cant set after init")
|
|
|
|
| 68 |
if 'query' not in st.session_state:
|
| 69 |
st.session_state.query = 'Genomics'
|
|
|
|
| 70 |
st.write(st.session_state.query)
|
| 71 |
|
| 72 |
+
# radio button persistance - plan is to hydrate when selected and change url along with textbox and search
|
| 73 |
+
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
| 74 |
+
query_params = st.experimental_get_query_params()
|
| 75 |
+
# set selectbox value based on query param, or provide a default
|
| 76 |
+
ix = 0
|
| 77 |
+
if query_params:
|
| 78 |
+
try:
|
| 79 |
+
q0 = query_params['query'][0]
|
| 80 |
+
ix = options.index(q0)
|
| 81 |
+
except ValueError:
|
| 82 |
+
pass
|
| 83 |
+
selected_option = st.radio(
|
| 84 |
+
"Param", options, index=ix, key="query", on_change=update_params
|
| 85 |
+
)
|
| 86 |
+
# set query param based on selection
|
| 87 |
+
st.experimental_set_query_params(option=selected_option)
|
| 88 |
+
|
| 89 |
|
| 90 |
|
| 91 |
|