On Mon, Feb 1, 2016 at 1:14 PM, [email protected] wrote:
- 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.
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.