【发布时间】:2017-11-06 21:05:47
【问题描述】:
尝试使用 Flask 运行静态 html。我不断收到错误:TemplateNotFound: lucky.html
我检查了另一篇类似的帖子:Flask Template Not found,但它对我的问题没有帮助。我试图移动包含lucky.html文件的模板目录,但没有成功
文件路径:
C:\Python27\flask_practice\templates
lucky.html
lucky.py
Python:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def lucky():
return render_template('lucky.html')
if __name__ == '__main__':
app.run()
HTML:
<html>
<body>
<p> Hello there </p>
<p> Feeling lucky </p>
<p> 7 </p>
</body>
</html>
【问题讨论】:
-
你能展示你的项目结构吗?
标签: python-2.7 flask