I started developing a template panel application (https://github.com/chime-experiment/bondia) using
my_template.show(). Now I would like to deploy it somewhere and make it accessible via web for multiple users. Changing
servable() and then passing the name of the script to
panel serve my_script.py does exactly what I want.
But I am wondering if I can somehow get the same functionality just by changing my script and calling it directly. This is to make deployment and configuration a little bit less awkward.
I also couldn’t find a way to pass a command line argument through
panel serve to my script (i.e.
--c my_config.yml). If I add an
--args before that, it would pass a
--index to my script (!?).
Welcome to the community.
You can actually use panel.serve. See the section Serving multiple apps at https://panel.holoviz.org/user_guide/Deploy_and_Export.html
Please note that Setting num_procs does not Work. I would really like it to as this is important when you start to have more users as i do at awesome-panel.org.
Please upvote the issue https://github.com/holoviz/panel/issues/1405 if this is important for you as well.
panel.serve(my_template) works, but it produces the same results as
template.show() (also if I pass
show=False to it):
It starts a server, but if I connect to it with two different browsers and interact with the plot in one browser, it also affects the plot in the other browser. I couldn’t find an option to change that. I think what is needed is that it starts an instance of panel for every user that connects to it.
The command line
panel serve myscript.py does that, I think. At least I managed to do that yesterday. Now it exits after I connect to it once and I don’t remember what the solution to that was.
If you pass a Panel object to
pn.serve it will indeed be shared between all sessions and this is to be expected. However you can pass a function to
pn.serve which will then be called and return a new object for each session.
That makes sense. Thanks!
I want to add here, that
server = MyServer()
works, but not
server = MyServer()
Thanks for that, would you mind filing an issue and/or PR? Looks like it’s only checking for
if isinstance(panel, FunctionType):
panel = panel()
Sure, I’ll have a look on Monday