| from urllib.parse import urlencode, parse_qs | |
| import streamlit as st | |
| st.json(st.session_state) | |
| 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  <img src="https://streamlit.io/images/brand/streamlit-mark-color.png" alt="Streamlit logo" height="16">  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, | |
| ) | |
| st.json(st.session_state) | |