So we serve a bokeh app using bokeh server document, the servable object was a gpsec, but I converted it to a panel Template kinda like this:
template = """
{%% extends base %%}
{%% block postamble %%}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://kit.fontawesome.com/2304e4818b.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
{%% endblock %%}
{%% block contents %%}
{%% set context = '%s' %%}
<div class="container" style="margin-left: 10px;">
<div class="row">
<div class="col">
{{ embed(roots.title) }}
</div>
<div class="col">
{{ embed(roots.actions) }}
</div>
</div>
{{ embed(roots.separator) }}
<div class="row">
<div class="col">
{{ embed(roots.widgets) }}
</div>
<div class="col">
{{ embed(roots.report) }}
</div>
</div>
</div>
{%% endblock %%}
"""
self.template = pn.Template(
template=(template % 'server'),
nb_template=(template % 'notebook'))
self.template.add_panel('fav', pn.Column(width=220, css_classes=['fav_place'], margin=0))
self.template.add_panel('title', self.info)
self.template.add_panel('actions', pn.Column(pn.Row(self.actions, align='center', margin=0), align='end', margin=0))
self.template.add_panel('separator', pn.Row(self.widget_box_show, pn.layout.Divider(margin=(0, 0, 0, 0), sizing_mode='stretch_width')))
self.template.add_panel('widgets', self.widget_box)
self.template.add_panel('report', report_area)
return self.template.servable()
The template has basically 3 rows of elements:
[title, button]
[button, separator]
[widget box, table of data or plots or whatever]
But that’s now how it renders. It renders each element down the left side of the screen:
It seems I’m unable to get the Template().servable() object to render correctly when serving the bokeh app (through flask) using the server_document from bokeh:
def route...
...
return render_template(
'base.html',
script=server_document(url=url, arguments=kwargs))
Should I be able to? If this is supposed to work, there must be something wrong on my end, maybe I have old bokeh js files or something, idk. Or perhaps panel Templates aren’t servable with bokeh server_document?
Any advice would be greatly appreciated. I did find a workaround using an iframe to serve it, but it requires me to rebuild a bunch of functionality which I’d like to avoid.
Thanks!