Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import IPython
|
| 3 |
import streamlit as st
|
| 4 |
import streamlit.components.v1 as components
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from IPython.display import IFrame
|
| 7 |
|
| 8 |
title = "AI Quantum - QGAN"
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import gradio as gr
|
| 3 |
import IPython
|
| 4 |
import streamlit as st
|
| 5 |
import streamlit.components.v1 as components
|
| 6 |
|
| 7 |
+
# query params exist
|
| 8 |
+
try:
|
| 9 |
+
options = ['cat', 'dog', 'mouse', 'bat', 'duck']
|
| 10 |
+
|
| 11 |
+
query_params = st.experimental_get_query_params()
|
| 12 |
+
query_option = query_params['option'][0] #throws an exception when visiting http://host:port
|
| 13 |
+
|
| 14 |
+
option_selected = st.sidebar.selectbox('Pick option',
|
| 15 |
+
options,
|
| 16 |
+
index=options.index(query_option))
|
| 17 |
+
if option_selected:
|
| 18 |
+
st.experimental_set_query_params(option=option_selected)
|
| 19 |
+
|
| 20 |
+
# run when query params don't exist. e.g on first launch
|
| 21 |
+
except: # catch exception and set query param to predefined value
|
| 22 |
+
options = ['cat', 'dog', 'mouse', 'bat', 'duck']
|
| 23 |
+
st.experimental_set_query_params(option=options[1]) # defaults to dog
|
| 24 |
+
|
| 25 |
+
query_params = st.experimental_get_query_params()
|
| 26 |
+
query_option = query_params['option'][0]
|
| 27 |
+
|
| 28 |
+
option_selected = st.sidebar.selectbox('Pick option',
|
| 29 |
+
options,
|
| 30 |
+
index=options.index(query_option))
|
| 31 |
+
if option_selected:
|
| 32 |
+
st.experimental_set_query_params(option=option_selected)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
from IPython.display import IFrame
|
| 38 |
|
| 39 |
title = "AI Quantum - QGAN"
|