Skip to content

Avoid boiler-plate when constructing a bokeh server programmatically #6565

Description

@mrocklin

In https://bokeh.github.io/blog/2017/6/29/simple_bokeh_server/ we discuss making a simple bokeh server from within Python.

from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from bokeh.plotting import figure, ColumnDataSource

def make_document(doc):
    fig = figure(title='Line plot!', sizing_mode='scale_width')
    fig.line(x=[1, 2, 3], y=[1, 4, 9])

    doc.title = "Hello, world!"
    doc.add_root(fig)

apps = {'/': Application(FunctionHandler(make_document))}

server = Server(apps, port=5000)
server.start()

It might be worth thinking about how to reduce the amount of code, and in particular the number of foreign terms that a beginning user needs to understand to make this work. In my ideal world the following might work:

from bokeh.plotting import figure, ColumnDataSource, Server

def make_document(doc):
    fig = figure(title='Line plot!', sizing_mode='scale_width')
    fig.line(x=[1, 2, 3], y=[1, 4, 9])

    doc.title = "Hello, world!"
    doc.add_root(fig)

apps = {'/': make_document}

server = Server(apps, port=5000)
server.start()

Activity

  1. modified the milestones: , 0.12.11 on Oct 11, 2017
  2. bryevdv commented on Oct 20, 2017

    @bryevdv
    Member

    closed by #7077

  3. github-actions commented on Oct 28, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  4. locked as resolved and limited conversation to collaborators on Oct 28, 2024
  5. added theissue type on Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions