Hi
RootHandler is a Tornado view handler that handles incoming HTTP requests to "/" on a Bokeh server. It's called a "handler" because that is the conventional terminology Tornado adopts for things that handle incoming requests. RootHandler just shows a list of all the currently running apps on a Bokeh server, and only if you don't also install your own app on "/" (which would take precedence).
But Bokeh has its own kinds of entirely different and unrelated "handlers". Specifically, ApplicationHanders (such as FunctionHandler), that handle creating instances of a Bokeh application. The term "handler" is one example (of many) of a term this is highly overloaded across different projects and languages.
In any case setting a template in the manner below works for me on Bokeh 1.0.2 so you will need to provide more information in order to investigate: version information, a complete script, including the template, and any data needed to run.
BTW is has not been necessary to create an Application and FunctionHandler explicitly for a long time. You can just pass the function directly:
server = Server({'/': modify_doc})
as demonstrated in all the examples here:
https://github.com/bokeh/bokeh/tree/master/examples/howto/server_embed
Those examples also demonstrate another way to apply a template by using the server_document function explicitly.
Thanks,
Bryan
> On Dec 24, 2018, at 08:34, acooke.org@gmail.com wrote:
>
> 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?)
>
> Thanks,
> Andrew
>
> PS And thanks for an interesting toolkit.
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
> To post to this group, send email to bokeh@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b728eb14-0f3d-4f44-9876-49db7930bfa8%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/4sfRL4IEG6M/unsubscribe\.
To unsubscribe from this group and all its topics, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/F307B4CA-43F6-4A18-807B-EC74868E605B%40anaconda.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.