jinja2.exceptions.TemplateNotFound: index.html
报错内容
jinja2.exceptions.TemplateNotFound: index.html
这是我在学习flask框架时,遇到的问题。试图加载html文件,调用static下的js内的函数。由于只是demo项目,故将
@app.route('/')
def index():
return render_template("index.html")
中的index.html文件 与 运行的py文件 放在同一级,这是导致该问题的我根本原因。
解决方法
在py同级目录下新建templates文件夹,将index.html放到该文件夹下。重新运行,成功!