我正在使用燒瓶並試圖讓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
我是新來的燒瓶。類似的回答並沒有幫助我解決這個問題。