【发布时间】:2014-10-28 10:05:50
【问题描述】:
我正在使用烧瓶并试图让 dygraph 样本工作。这是示例代码(教程页面中的第二个示例:http://dygraphs.com/tutorial.html):
<html>
<head>
<script type="text/javascript"
src="dygraph-combined.js"></script>
</head>
<body>
<div id="graphdiv2"
style="width:500px; height:300px;"></div>
<script type="text/javascript">
g2 = new Dygraph(
document.getElementById("graphdiv2"),
"temperatures.csv", // path to CSV file
{} // options
);
</script>
</body>
</html>
这是我的 Flask 代码(我正在尝试使用 render_template()):
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def render_plot():
return render_template('sample.html')
if __name__ == '__main__':
app.run()
当我通过 python firebug 运行它时,出现错误“Dygraph 未定义”。从线 g2 = new Dygraph(
Sample.html 在我的文件夹中工作,但是当我从 python 运行烧瓶代码后尝试从我的 url 访问它时它不起作用。我的文件夹如下所示:
FlaskStuff/main.py
FlaskStuff/templates/sample.html
FlaskStuff/templates/dygraph-combined.js(在我的文件夹中加载 sample.html)。
FlaskStuff/js/dygraph-combined.js
我是 Flask 的新手。类似的答案并没有帮助我解决这个问题。
【问题讨论】: