Skip to content

Server Options

hover creates a bokeh server app to deliver its annotation interface.

🚀 This app can be served flexibly based on your needs.


Suppose that we've already used a recipe to create a handle function like in the quickstart.

Recap from the tutorials before
  • the handle is a function which renders plot elements on a bokeh document.

Option 1: Jupyter

We are probably familiar with this now:

from import show, output_notebook
show(handle) # notebook_url='http://localhost:8888'
Pros & Cons

This inline Jupyter mode can integrate particularly well with your notebook workflow. For example, when your are (tentatively) done with annotation, the SupervisableDataset can be accessed directly in the notebook, rather than exported to a file and loaded back.

The inline mode is highly recommended for local usage. However, with a remote Jupyter server, it has trouble loading JS libraries or accessing implicit bokeh server ports.

Option 2: Command Line

bokeh serve starts an explicit tornado server from the command line:

bokeh serve

# handle = ...

from import curdoc
doc = curdoc()
Pros & Cons

This is the "classic" approach to run a bokeh server. Remote access is simple through parameters specified here. The bokeh plot tools are mobile-friendly too -- this means you can host a server, e.g. an http-enabled cloud virtual machine, and annotate from a tablet.

The command line mode is less interactive, since Python objects in the script cannot be accessed on the fly.

Option 3: Anywhere in Python

It is possible to embed the app in regular Python:

from bokeh.server.server import Server
server = Server({'/my-app': handle})
Pros & Cons

This embedded mode is a go-to for serving within a greater application.

Also note that each command line argument for bokeh serve has a corresponding keyword argument to Server().

For instance, bokeh serve <args> --allow-websocket-origin=* in the command line mirrors Server(*args, allow_websocket_origin='*') in Python.

The embedded mode gives you the most control of your server.