jinja2.exceptions.TemplateNotFound: index.html

465 阅读1分钟

jinja2.exceptions.TemplateNotFound: index.html

在学习Flask中出现的报错,一起踩坑吧! 现象 GET /index HTTP/1.1" 500 内部服务器错误 return render_template(“index.html”) #调用模块index jinja2.exceptions.TemplateNotFound: index.html 没有找到index.html文件

原因 由于reder_template查找目录是在当前目录中查找templates,我创建的templates文件夹不在当前目录中,因此找不到index.html文件。

解决方法 此程序所在目录下创建一个templates文件夹,将index,html文件放入其中即可。