File size: 1,338 Bytes
a18878f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from urllib.parse import urlencode, parse_qs
import streamlit as st

initial_query_params = st.session_state.get("initial_query_params")
query_params = {k: v[0] for k, v in st.experimental_get_query_params().items()}
if not initial_query_params:
    initial_query_params = query_params.copy()
    st.session_state["initial_query_params"] = initial_query_params.copy()

st.write("Initial query params of the session:", initial_query_params)
st.write("Query params before setting new ones:", query_params)

new_query_string = st.text_area("New query params string (like 'a=b&c=d')", value=urlencode(initial_query_params))
if st.button("Set new query params without starting new session"):
    st.experimental_set_query_params(**parse_qs(new_query_string))

with st.sidebar:
    st.markdown("---")
    st.markdown(
        '<h6>Made in &nbsp<img src="https://streamlit.io/images/brand/streamlit-mark-color.png" alt="Streamlit logo" height="16">&nbsp by <a href="https://twitter.com/andfanilo">@andfanilo</a></h6>',
        unsafe_allow_html=True,
    )
    st.markdown(
        '<div style="margin-top: 0.75em;"><a href="https://www.buymeacoffee.com/andfanilo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a></div>',
        unsafe_allow_html=True,
    )