Panel server for multiple users

Hi everyone! I am deploying an application using a panel and encountered the problem described here Unable to to serve datas. That is, multiple users cannot independently use the application.
But the proposed solution is for Boquet’s server. I would like to know how to implement the same thing only for the Panel.
My code is very simple and looks like this:

def callback():
      return some_hv_object

dmap = hv.DynamicMap(callback)
rastered = rasterize(dmap)
pn.serve(rastered, port=5000, show=False)

you need to put your app in a function, and not like a global object. The server will call the function get_page_user each time a new user requests the app page.

import panel as pn 
import holoviews as hv

def get page_user():
    def callback():
        return some_hv_object

    dmap = hv.DynamicMap(callback)
    rastered = rasterize(dmap)

    return rastered

pn.serve(get_page_user, port=5000, show=False)
2 Likes

Thank you very much! Unfortunately, I could not understand from the documentation what exactly to do this way.

Probably it is not declared in the documentation, if you can guide us where to put this it would be great. I agree with you that good examples of multi-user applications are missing, or at least I don’t know where to find them either.