this may have been asked in different threads previously, e.g., there is a related thread, however it’s more than a year old and my question is slightly different:
Now that there is some rudimentary session management in streamlit, I was wondering if there was a simple way to encode/hash the entire app state into the URL – so that a URL exists that users can share e.g. to discuss a certain view on some visualised data. So I don’t just want the URL to contain which subpage is viewed but also the state of all checkboxes, sliders, et cetera. Any ideas how this could be archieved?
I’m not sure how it was done, but @AustinC has created an app that does something similar. It super cool, and allows the user to type up some Streamlit code in an editor and the output is displayed next to it. Then, you can hit a button “share your work” and a url is generated that saves the current state to send to people! Here is the link
@AustinC maybe you can post your github link to the code you used?
I use something similar for a ML lifecycle management application I built for my client using streamlit to share experiments. The better thing to do would be to save this session state json in a mongodb or some where else and just set the uid as a URL param and pick up the state on run of main from DB.
Because the URL params cant hold more than 2048 chars
Hope it helps !
PS. I think Austin is doing something similar, perhaps just dumping the JSONs on fs instead of a document store and all.
And if you’re already using the other session_state hack from here you could also do it like I show here where I also show a way of setting state of other widgets by the click of a button
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.