Saving Bokeh Server Instance as Standalone Interactive HTML file

Hi again

I’m in a project that uses many Graphical libraries in a python notebook. All the functionallity is finally merged in a Panel app which can be displayed either in the jupyter cell or in a new tab in the browser. The second option is done using panel.show(), which, according to documentation it creates a Bokeh Server Instance. In this new tab i cn use all the interaction features i included to the app, the only problem is that the only way of opening this app is:
1) Opening the notebook in JupyterLab
2) Running the cells with all the Python functions used in the Panel
3) Running the cell where the Panel is made, adding in the end a line of code that when executed, opens a new tab and displays the APP.

cap1

The idea is to save this tab as an Standalone HTML to save all the previous steps, i want the user to simply double click this HTML and so it will get into the Bokeh Server Instance and start using the App.

I’ve read Embedding Bokeh content — Bokeh 2.4.3 Documentation , which looks like the idea i want but i don’t fully understand it.

Thanks a lot :smiley:

The idea is to save this tab as an Standalone HTML

Taken literally, this is impossible. Standalone HTML output is just that: nothing but static HTML (and JS). Standalone HTML output has no connection ever or at all to any Bokeh server. So nothing about standalone HTML (e.g. embedding APIs for standalone HTML) is applicable or will be of any use to a Bokeh server app situation.

But assuming you mean you want some simpler/different way for users to access a running Bokeh server app, then there are several interpretations of your post. It’s not clear what your actual expectations are.

  • Is the Bokeh server app running remotely, and you want something users can click on to connect to the remote Bokeh server?

  • Or you want users to click something, and it starts the Bokeh server on their local machine and raises a browser window?

  • If so, do you expect them to have Python and Bokeh and all other necessary dependencies already installed? Or you want literally a self-contained “app” ala what pyinstaller or py2exe try to provide?

1 Like

I’ll also reiterate my earlier advice. Panel is a separate piece of software, and although it uses the Bokeh server internally, it has its own unique features and considerations, different from Bokeh. The fact that you are using Panel at all really means that the best place to start with questions is not here, but is instead the Holoviz discourse (run by the Panel developers): https://discourse.holoviz.org

1 Like

Right; the Panel section of the HoloViz discourse is what you need. But to reiterate and clarify some of Bryan’s points:

  • If you want to launch a server without using JupyterLab, just change “.show()” to “.serveable()”, and then run panel serve your_notebook.ipynb. The resulting Python process will work just like .show did from Jupyter Lab, but no longer needing Jupyter or Jupyter Lab at all.

  • The resulting web page still relies on an underlying Bokeh Server python process, and thus is not just an HTML file. To share that, you can’t just send an HTML file around, you’ll have to follow the instructions in the Deployment section of the Panel user manual.

  • Even though you always do need python for a Bokeh-server-based Panel app (as Bryan mentions), there is now a way to run Python directly in your browser using PyScript (see https://pyscript.net). Panel 0.14 will be released very soon and can export certain apps directly to a standalone HTML file with PyScript that can be used in the way you are requesting. But please note that PyScript is very, very new and only supported in certain cases. When you can use it, you can indeed generate a standalone HTML file that can be distributed and viewed easily. But it will take some work to document how to do this, with special care needed for accessing data files and other common tasks. There are examples at PyScript demo (search the page for Panel) that show what’s possible, and if that helps get you started, great! But if it doesn’t, we won’t be able to help much, because PyScript is under very active development and we have to focus on that rather than support questions.

2 Likes

Any of this 2 ideas would be fine :smiley:

  • Or you want users to click something, and it starts the Bokeh server on their local machine and raises a browser window?
  • If so, do you expect them to have Python and Bokeh and all other necessary dependencies already installed? Or you want literally a self-contained “app” ala what pyinstaller or py2exe try to provide?