Both FunctionHandler and RootHandler have similar names, but they seem to be different conceptually (one is a server view and the other an application handler).
I have code that uses the Bokeh server to “push” a (non-interactive) plot to the browser. The code looks like:
def show(log, plot):
def modify_doc(doc): doc.add_root(plot) app = Application(FunctionHandler(modify_doc)) server = Server(app) server.start() log.info('Opening Bokeh application on http://localhost:5006/') server.io_loop.add_callback(server.show, "/") server.io_loop.call_later(5, server.io_loop.stop) server.io_loop.start()
and works fine. However, it’s kinda ugly. So I tried something like:
def modify_doc(doc): doc.add_root(plot) doc.template_variables['title'] = 'Hello World' doc.template = '''a template here based on FILE'''
which didn’t have the effect I expected. In fact, the template wasn’t used at all. Instead, my FunctionHandler seems to be being rendered(? wrapped?) by RootHandler using app_index.html.
Hence the question. Where does RootHandler come from? How can I either avoid it or modify it?
I feel like I’m missing something in the docs - I haven’t found anything that’s a fairly high-level overview that explains RootHandler.
(I realise I could use a file-system based application and this wouldn’t be an issue. Am I dumb to want to do this in Python?)
PS And thanks for an interesting toolkit.