jinja2.exceptions.TemplateNotFound:templates / entry.html

时间:2019-04-11 11:32:30

标签: python-3.x

from flask import Flask,render_template

app=Flask(__name__)
@app.route('/entry',method=['POST','GET'])

def entry():
    return render_template('entry.html',the_title='welcome to entry ')

@app.run(debug=True)

1 个答案:

答案 0 :(得分:0)

您必须在正确的位置创建模板文件;在您的python模块旁边的templates子目录中。

该错误表明entry.html目录中没有templates/文件。确保在与python模块相同的目录中创建了该目录,并且实际上确实在该子目录中放置了entry.html文件。

myproject/
  app.py
  templates/
    entry.html

如果您的应用是软件包,则应在软件包内部创建templates文件夹。

myproject/
   mypackage/
      __init__.py
      templates/
         entry.html