New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrocklin opened this Issue Jun 29, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@mrocklin
Contributor

mrocklin commented Jun 29, 2017

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()
@bryevdv

This comment has been minimized.

Member

bryevdv commented Oct 20, 2017

closed by #7077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment