错误 TemplateNotFound:来自烧瓶的 hello.html
error TemplateNotFound: hello.html from flask
File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 64, in get_source
raise TemplateNotFound(template)
TemplateNotFound: hello.html
app.py的脚本:
from flask import Flask
from flask import request
from flask import render_template
APP = Flask(_name__)
@APP.route('/')
def hello():
return render_template('hello.html')
if _name__ == '_main__':
APP.debug=True
APP.run()
我的目录结构:
app/
├── app.py
├── app.py~
├── static
│ └── style.css
└── template
├── hello.html
└── hello.html~
默认的模板目录名称是templates
,复数形式。你错过了最后的 s
。
或者,告诉 Flask 查看不同的目录名称:
APP = Flask(_name__, template_folder='template')
File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 64, in get_source
raise TemplateNotFound(template)
TemplateNotFound: hello.html
app.py的脚本:
from flask import Flask
from flask import request
from flask import render_template
APP = Flask(_name__)
@APP.route('/')
def hello():
return render_template('hello.html')
if _name__ == '_main__':
APP.debug=True
APP.run()
我的目录结构:
app/
├── app.py
├── app.py~
├── static
│ └── style.css
└── template
├── hello.html
└── hello.html~
默认的模板目录名称是templates
,复数形式。你错过了最后的 s
。
或者,告诉 Flask 查看不同的目录名称:
APP = Flask(_name__, template_folder='template')