Paste "Bokeh created html file" into the file "template.html" Flask

I have a web application written in Python-Flask. When a user fills in some settings on one of the pages (POST request), my controller calculates some functions and displays the result using Bokeh with the following command, and then I redirect to this HTML page created by Bokeh.

output_file("templates\\" + idx[j]['name'] + ".html", title = "line plots")
TOOLS="resize,crosshair,pan,wheel_zoom,box_zoom,reset,box_select,lasso_select"
p = figure(tools=TOOLS, x_axis_label = 'time', y_axis_label = 'L', plot_width = 1400, plot_height = 900)

All my HTML pages expand my Template.HTML file, except for those created by Bokeh. My question is, how can I automatically modify the generated HTML Bokeh files, also expanding my template.html file? This way I have all my nav-bar and jumbotron on top of the html Bokeh files.

  {% extends "template.html" %}
  {% block content %}

  <Bokeh.html file>

  {% endblock %}
+4
1

output_file. Bokeh HTML- -, bokeh.embed.component, quickstart tutorial.

from bokeh.embed import components
script, div = components(plot)
return render_template('page.html', script=script, div=div)
<body>
{{ div|safe }}
{{ script|safe }}
</body>

, , , Flask.

+12

Source: https://habr.com/ru/post/1613544/


All Articles