I am creating a Bokeh Plot, and passing the html code script, div = components(plot)
return render_template('results.html',the_div=div,the_script=script)
脚本和div已传递到浏览器,但是没有看到图,而是显示了html代码。
{% extends "bootstrap/base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block html_attribs %} lang="en" charset="utf-8"{% endblock %}
{% block title %} Prottiming Results {% endblock %}
{% block metas %}
<link rel="icon" type="image/png" href="https://www.pythonanywhere.com/user/morganprott/files/home/morganprott/mysite/static/favicon-96x96.png">
<link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js"
crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.0.2.min.js"
crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.0.2.min.js"
crossorigin="anonymous"></script>
{% endblock %}
{% block content %}
<div class="container">
{{ the_script }}
{{ the_div }}
</div>
有人可以指出我要去哪里了吗? -我检查我使用的bokeh版本是2.0.2 我不熟悉javascript,因此我认为这可能是一个简单的解决方法
By default, all template parameters are escaped to prevent them from altering the DOM structure. Since you do need to alter the DOM structure, you should just add
|save
to each variable:More details: https://jinja.palletsprojects.com/en/2.11.x/templates/#working-with-automatic-escaping