【发布时间】: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
而且它并不是特别有启发性。我的模板文件夹在目录树中的应用程序旁边。我敢肯定这很简单,但我没有看到。
【问题讨论】: