【发布时间】:2017-04-26 11:25:35
【问题描述】:
您好
我有一个烧瓶应用程序:
@app.route('/test')
def test():
return render_template('index.html')
在 index.html 中我有:
<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css">
.node {
cursor: pointer;
}
.overlay{
background-color: #e6d1ee;
}
.node circle {
fill: #fff;
stroke: #4d4bb4;
stroke-width: 2px;
}
.node text {
font-size:10px;
font-family:sans-serif;
}
.link {
fill: none;
stroke: #7acc7e;
stroke-width: 2px;
}
.templink {
fill: none;
stroke: #ff8285;
stroke-width: 3px;
}
.ghostCircle.show{
display:block;
}
.ghostCircle, .activeDrag .ghostCircle{
display: none;
}
</style>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="MyTree.js"></script>
<body>
<div id="tree-container"></div>
</body>
当我在浏览器中运行这段 html 代码时,它显示了一个很好的 graph
然后我使用带有render_template的flask渲染它,它显示出绝对注意到
我该如何解决?
抱歉这个巨大的代码块,我不确定这是 html 问题
更新:
实际上是的,问题出在静态的东西上。现在我的浏览器可以获取 js 文件。但又出现了一个问题。在我正在使用的 MyTree.js 中
treeJSON = d3.json("{{ url_for('static', filename='dota.json') }}", function(error, treeData)
并且 dota.json 没有在浏览器中加载。但它与 MyTree.js 在同一个目录中,在静态目录中。
【问题讨论】:
-
什么负责为 MyTree.js 提供服务?
-
查看快速入门flask.pocoo.org/docs/0.12/quickstart中的静态文件部分