Skip to content
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 · Fixed by #7077
Closed

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

mrocklin opened this issue Jun 29, 2017 · 1 comment · Fixed by #7077

Comments

@mrocklin
Copy link
Contributor

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
Copy link
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants