st.server_state
with endpoint access (like st.session_state
, but for global values; different from pickled user sessions)
#10067
Labels
Checklist
Summary
Currently, we can use
st.cache_data
andst.cache_resource
to "save" values that can be accessed between sessions. What if there was an API similar tost.session_state
that was shared between sessions? I suggestst.server_state
.Additionally, a Streamlit app could include an endpoint for accessing and updating server state.
Why?
A common pattern is for a Streamlit app to reach out and collect data from a remote location, typically saving it with
st.cache_data
. If there was some server state combined with an endpoint, a remote source could be able to ping the app and initiate an update of data. This prevents needing to schedule an app to run to update data or making a random user wait if they are the first to connect beyond a cached values TTL.This would also be useful for IoT use cases where a smart device can send an alert to the app.
Another feature request to send a global message to all sessions (#7312) could also be accommodated with this.
How?
Add a new API
st.server_state
which is global with all sessions having read/write access.Add an (authenticated) enpoint for remote sources to connect to and update values in
st.server_state
.Additional Context
This is related to requests for app state (#8609), but I'm suggesting something narrower.
The text was updated successfully, but these errors were encountered: