Embed "Bokeh created html file" into Flask "template.html" file
You don't want to use output_file
in this situation. Bokeh has a function specifically for embedding into HTML templates in web apps, bokeh.embed.component
, demonstrated in the quickstart and tutorial.
from bokeh.embed import componentsscript, div = components(plot)return render_template('page.html', script=script, div=div)
<body>{{ div|safe }}{{ script|safe }}</body>
Here is a complete, runnable example that that shows how to use this with Flask.