Deploying app for multiple users and embedding within HTML

Hi,

I’m building a simple web app to be used by participants in a high school science competition. Bokeh seemed like a great tool to use for this, since we want to give participants the ability to re-run a simple box model with different settings, and get some feedback on what has changed in the model system. The previous link is the basic version of my app working as a Bokeh standalone application, but in order to polish this off, I had a few questions for the community:

  1. Is it possible to use the bokeh server to deploy this app such that different users will be able to pull it up in their browser and make custom plots? For instance, can Team A and Team B both log into the app at the same time and not interfere with each other’s plots? This seems to work okay if I open up multiple browser tabs when I run bokeh server locally, but I was curious if anyone had tried to scale this up (I’ll have about two dozen teams that will need to interact with it).
  2. Is there a simple way to embed my existing application (link above) into a slightly more complex web page? For instance, we have some text description to go along with the model. Most importantly, we have a mockup of a simple schematic of the model as an SVG which I plan on re-drawing each time the model is run, with elements on the schematic changed according to (a) the result from the model run and (b) the parameters used to run the model. It’s easy enough to use Javascript callbacks on the “run model” button on my app to trigger changing the elements of the SVG, but I can’t seem to find a simple way to construct the webpage to include both the app and our supplemental details.
    Thanks for your help!

Hi,

On Mon, Feb 1, 2016 at 1:14 PM, [email protected] wrote:

  1. Is it possible to use the bokeh server to deploy this app such that different users will be able to pull it up in their browser and make custom plots? For instance, can Team A and Team B both log into the app at the same time and not interfere with each other’s plots? This seems to work okay if I open up multiple browser tabs when I run bokeh server locally, but I was curious if anyone had tried to scale this up (I’ll have about two dozen teams that will need to interact with it).

Yes! This is how http://demo.bokehplots.com/ works. The normal case for bokeh server is that each tab gets its own “instance” of the bokeh.document.Document.

  1. Is there a simple way to embed my existing application (link above) into a slightly more complex web page? For instance, we have some text description to go along with the model. Most importantly, we have a mockup of a simple schematic of the model as an SVG which I plan on re-drawing each time the model is run, with elements on the schematic changed according to (a) the result from the model run and (b) the parameters used to run the model. It’s easy enough to use Javascript callbacks on the “run model” button on my app to trigger changing the elements of the SVG, but I can’t seem to find a simple way to construct the webpage to include both the app and our supplemental details.

This is harder than it should be right now because you have to make a web server just to serve the one web page, rather than bokeh server itself doing it.

Some options are:

  • run two processes, 1) web framework of your choice, maybe even just a web server like apache or nginx with a static html file, plus 2) bokeh server. Run autoload_server to generate the chunk of script that embeds a bokeh serve plot; pass it your bokeh server url and app_path. Stick the autoload_server HTML in the HTML your web server generates. It is important to use session_id=None with autoload_server so every page load gets a new Bokeh session (your first question). If you provide a session_id to autoload_server then every page load will use that same session.

  • to avoid multiple processes: instead of the bokeh serve command write your own very simple equivalent using the Server class (some tech notes at http://bokeh.pydata.org/en/dev/docs/dev_guide/server.html but not exactly a tutorial). What I’d do is look at the source to the serve command here: https://github.com/bokeh/bokeh/blob/0.11.0/bokeh/command/subcommands/serve.py … the steps are, build Application instances, then pass them in to Server, then server.start(). To do your simple web page, you’d add an extra_patterns to Server, which is where you can pass in a tornado request handler that serves html. The tornado docs cover making a request handler but essentially it’s an object with a get() method and get calls self.write(myhtml), IIRC. Maybe also sets content type.

What would be great in the future I think would be if a “directory-style” bokeh app could have HTML files in there which were automatically made available, and there were a way to say “put the autoload_server embed here” inside those HTML files. Alternatively, maybe some kind of HTMLChunk bokeh widget, which would be a little widget that contains an HTML template and “slots” for child models. Not sure of the details. But I do think it would be great to have something like that since your use case (“put a little html around my bokeh stuff”) is very common.

I agree, this is a very common use case...

What would be great in the future I think would be if a "directory-style"
bokeh app could have HTML files in there which were automatically made
available, and there were a way to say "put the autoload_server embed here"
inside those HTML files. Alternatively, maybe some kind of HTMLChunk bokeh
widget, which would be a little widget that contains an HTML template and
"slots" for child models. Not sure of the details. But I do think it would
be great to have something like that since your use case ("put a little
html around my bokeh stuff") is very common.

This is all very useful - thanks for the information!

I have the same use-case as the author of this post. The point 1. solution (http://demo.bokehplots.com/) is no longer available. Is there any other implementation to the problem described below:

" 1. Is it possible to use the bokeh server to deploy a flask app such that different users will be able to pull it up in their browser and make custom plots? For instance, can Team A and Team B both log into the app at the same time and not interfere with each other’s plots? This seems to work okay if I open up multiple browser tabs when I run bokeh server locally, but I was curious if anyone had tried to scale this up (I’ll have about two dozen teams that will need to interact with it)."

@GarvKhurana the demo site was moved to demo.bokeh.org (all Bokeh web properties are now consolidated under the single bokeh.org domain)

Apart from that, it would be much easier to help if you open a brand new topic that describes your actual specific use case, so that we can not avoid any confusions from very old posts and answers.

Thank you Bryan for your response. I have figured out the solution to this issue but I will follow your advice next time on.

Anyhow, I am loving to use bokeh.

1 Like