The Bokeh server provides a modality for running Bokeh applications with greater interactive functionality than the standalone plotting examples we have considered previously. The server facilitates this by enabling interactive web applications that connect front-end user interface events to back-end Python code. The Bokeh user guide states, perhaps somewhat obliquely, that: "The primary purpose of the Bokeh server is to synchronize data between the underlying Python environment and the BokehJS library running in the browser."

With Bokeh server, you can:

  • modify what gets displayed in Bokeh plots based on user interactions
  • trigger new computations based on user interactions
  • create data / analysis dashboards with multiple widgets for displaying and interacting with data
  • run the same code locally within a web browser or serve it up to others on the internet

The action of the Bokeh server is depicted in the figure below. The "App Code" running on a Bokeh Server is Python code that implements both calls to the Bokeh Python API and whatever business / science / application logic that one wants to implement in order to process data. A separate running copy of a Bokeh Document is served up to however many Browser clients connect to the server at a given time, enabling multiple clients to connect to the same server simultaneously and without crosstalk between application instances. The Document is rendered within the Browser, and events initiated in the client trigger callback functions that run within the App Code on the Server, typically resulting in updates to plotted data.

Bokeh server software architecture
Bokeh server architecture and interactions with browser clients (source: https://docs.bokeh.org/en/latest/_images/bokeh_serve.svg)

In order to run a Bokeh server application, one runs the "bokeh" program on the command line. For example, if the program "myapp.py" contains the Python+Bokeh code that you want to run, you can serve it up within your local browser with the following command:

The resulting application will be accessible in your browser (running on your localhost on a default port) at the address

A sample small Bokeh server application can be found in the Bokeh documentation on Building applications.

Alternatively, if you would like to serve up one or more Bokeh applications on a webserver, you could run "bokeh serve" with additional configuration options, as described in the Bokeh documentation on Deployment scenarios.

In the following pages, we will explore the Bokeh server and its components in more detail.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement