我正在使用烧瓶并试图让dygraph样本工作。下面是示例代码(从教程页面示例2:http://dygraphs.com/tutorial.html):Dygraph没有定义,使用Flask
<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>
这里是我的瓶代码(我试图使用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萤火虫给我错误“Dygraph没有定义。”从线G2 =新Dygraph(
Sample.html作品在我的文件夹中,但是当我试图从Python的运行我的烧瓶代码之后,从我的网址访问它,它不工作我的文件夹是这样的:
FlaskStuff/main.py
FlaskStuff /模板/ sample.html
FlaskStuff /模板/ dygraph-combined.js(要我的文件夹中加载sample.html)。
FlaskStuff/JS/dygraph-combined.js
我是新来的烧瓶。类似的回答并没有帮助我解决这个问题。