Jinja2 将html文件包含到bokeh独立服务器中

Jinja2 将html文件包含到bokeh独立服务器中,jinja2,bokeh,Jinja2,Bokeh,如何将自定义jinja2 html文件包含到Bokeh服务器嵌入示例程序中? 见: 默认情况下,在templates/index.html中加载html文件与在目录格式Bokeh server中加载html文件不同。添加到服务器嵌入示例文件: 来自jinja2导入模板的 并在modify_文档功能中添加: with open('./path/to/my.html') as f: index_template = Template(f.read()) doc.template = inde

如何将自定义jinja2 html文件包含到Bokeh服务器嵌入示例程序中? 见:
默认情况下,在templates/index.html中加载html文件与在目录格式Bokeh server中加载html文件不同。

添加到服务器嵌入示例文件:

来自jinja2导入模板的

并在
modify_文档
功能中添加:

with open('./path/to/my.html') as f:
    index_template = Template(f.read())
doc.template = index_template
这是因为文档对象具有 博克似乎为我们呈现了这一点

还包括jinja2模板中的bokeh变量:

<head>
    {{ bokeh_css }}
    {{ bokeh_js }}
</head>

{{bokeh_css}}
{{bokeh_js}
该机构应具备:

<body>
    {{ plot_div|indent(8) }}
    {{ plot_script|indent(8) }}
</body>

{{plot_div | indent(8)}
{{plot_script}缩进(8)}