Python Flask找不到模板文件-jinja2.exceptions.TemplateNotFound

Python Flask找不到模板文件-jinja2.exceptions.TemplateNotFound,python,flask,Python,Flask,我试图在Python中使用Flask(Jinja2)呈现一个“html”文件,但它显示了一个错误。 我的控制器“.py文件”:- 错误消息显示: jinja2.exceptions.TemplateNotFound:template\profile.html templates文件夹应命名为templates(复数),并保存在应用程序的根路径中。这就是Flask默认的工作方式。错误消息显示: jinja2.exceptions.TemplateNotFound:template\profile.

我试图在Python中使用Flask(Jinja2)呈现一个“html”文件,但它显示了一个错误。 我的控制器“.py文件”:-


错误消息显示:

jinja2.exceptions.TemplateNotFound:template\profile.html


templates文件夹应命名为
templates
(复数),并保存在应用程序的根路径中。这就是Flask默认的工作方式。

错误消息显示:

jinja2.exceptions.TemplateNotFound:template\profile.html

templates文件夹应命名为
templates
(复数),并保存在应用程序的根路径中。这就是烧瓶默认的工作方式。

试试这个:
app=Flask(\uuuuu name\uuuuuuu,template\u folder={template directory的路径})
试试这个:

app=Flask(\uuu name\uuuuu,template\u folder={path of template directory})

服务器上是否存在
profile.html
文件,路径是否正确?反斜杠似乎可疑…它位于template\profile.html中。该文件夹应称为
templates
,而不是
template
,默认情况下,html模板的文件夹是
templates
。将文件夹名
template
更改为
templates
,这将解决您的问题。如果服务器上存在路径正确的
profile.html
文件,并且反斜杠似乎可疑…它位于template\profile.htmlt中,则该文件夹应称为
templates
,而不是
template
,默认情况下,html模板的文件夹是
templates
。将文件夹名
template
更改为
templates
,这将解决您的问题
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/profile/<name>")
def profile(name):
    return render_template('profile.html', name=name)
if __name__ == "__main__":
    app.run(debug=True)
<h1>Welcome To Your Profile, {{ name }}</h1>
  jinja2.exceptions.TemplateNotFound: template\profile.html