jinja2.exceptions.TemplateNotFound: index.html 错误

jinja2.exceptions.TemplateNotFound: index.html error

我正在尝试渲染文件 index.html,但我不断收到

jinja2.exceptions.TemplateNotFound: index.html

当我尝试渲染它时。为什么 Flask 找不到我的模板

app=Flask(__name__,template_folder='templates')


@app.route("/")
def index():
    return render_template('index.html')

我的文件位置就像(我有机会使用 Tamplates to tamplates)

所以你必须像这样定义模板文件夹路径。

如果您将模板文件夹命名为:Tamplates

然后用这个

app = Flask(__name__, template_folder='Tamplates')