I’m creating a web application using Bokeh. My application allows users to retrieve data from a database and perform minor transformations on the data in addition to visualizing the data.
One issue that I’ve come across is that if the browser page is reloaded, then a new session is started and the user loses all the work that was performed. Is there a way to prevent this?
I have a main.py module that contains all the bokeh code, essentially:
from bokeh.io import curdoc
doc = curdoc()
# Create UI elements and layout
# ...
doc.add_root(layout)
And I start the server from my python environment:
>> bokeh serve --show main.py
It appears to me that on reload of the webpage, bokeh does not use the same session/document, but drops the websocket connection, connects a new websocket and creates a new session and document. The bokeh server is still using the same Python process, so I suspect the original session/document may still exist (unless there are no longer any references).
Is there a way to maintain a websocket connection or use an existing session/document if the webpage is (accidentally) reloaded, or even prevent the page from reloading?
Or perhaps I’m implementing this application incorrectly?

