Single Session Different Clients

I am trying to deploy Plot with Columns on this URL: Plot With Columns — Panel v0.13.0

When I run the application o a server and visit the address on my local machine I can use the app. The app is also reachable by other machines with an unexpected feature. Whenever I make a change on the sidebar it is reflected to the other user immediately by the WebSocket. But I need each client to have their own session. Also, the graph in the center does not have this property. I can zoom or move the visual, and it does not reflect other users.

My code is here:

import panel as pn
import hvplot.pandas

from bokeh.sampledata.autompg import autompg_clean


quant = [None, 'mpg', 'cyl', 'displ', 'hp', 'weight', 'yr']
cat = [None, 'origin', 'mfr', 'yr']
combined = quant+cat[1:]

x = pn.widgets.Select(name='x', value='mpg', options=combined)
y = pn.widgets.Select(name='y', value='cyl', options=combined)
color = pn.widgets.Select(name='color', options=combined)
facet = pn.widgets.Select(name='facet', options=cat)

@pn.depends(x, y, color, facet)
def plot(x, y, color, facet):
    cmap = 'Category10' if color in cat else 'viridis'
    return autompg_clean.hvplot.scatter(
        x, y, color=color or 'green', by=facet, subplots=True, padding=0.1,
        cmap=cmap, responsive=True, min_height=500, size=100

settings = pn.Row(pn.WidgetBox(x, y, color, facet))
    '### Auto MPG Explorer', 

plot = pn.template.FastListTemplate(
    site="Panel", title="Auto MPG Explorer", sidebar=[settings], 
    main=["This example demonstrates **how to combine multiple columns of components into an overall layout**.", plot]

pn.serve(plot, port=3000,  show=True)

1 Like

The issue is that you instantiate one plot to serve/ share between all users. It can in some situations be handy (“live-share”). But not here.

Instead you need to provide a function get_plot to pn.serve that returns a new plot for each session.

I would actually advice on 1) using panel serve 2) remove pn.serve... and 3) add plot.servable(). That should also solve your problem

panel serve is very widely used and in my experience works the best.