错误TemplateNotFound:来自于烧瓶的hello.html

时间:2015-04-05 15:04:21

标签: python 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~

1 个答案:

答案 0 :(得分:3)

默认模板目录名称为 templates ,复数形式。你最后错过了s

或者,告诉Flask查看不同的目录名称:

APP = Flask(_name__, template_folder='template')