【问题标题】:Flask render_template TemplateNotFound [duplicate]Flask render_template TemplateNotFound [重复]
【发布时间】:2015-05-18 18:44:38
【问题描述】:

我正在修补 Flask 以使用 Postgres,并且 db 的东西正在顺利进行,但令人烦恼的是,我无法让 render_template 工作。以下是相关位:

app.py

from flask import Flask, render_template
app = Flask(__name__)
@app.route("/test2/")
def test2():
    return render_template('test2.html')
if __name__ == "__main__":
    app.debug = True
    app.run()

文件 test2.html 位于 ./templates 目录中。当我运行应用程序并点击该网址时,我得到jinja2.exceptions.TemplateNotFound

所以我看过这个:

Python - Flask: render_template() not found

而且它并不是特别有启发性。我的模板文件夹在目录树中的应用程序旁边。我敢肯定这很简单,但我没有看到。

【问题讨论】:

    标签: python flask


    【解决方案1】:

    好吧,我是个笨蛋。在命令行上 git commit 我的更改,看到模板目录在父目录中。在 Finder 中看起来不是这样。

    【讨论】:

      猜你喜欢
      • 2016-06-10
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 2014-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多