更改Flask模板的根文件夹:jinja2.exceptions.TemplateNotFound

问题描述

我有一个具有以下结构的应用程序:

/Backend
    app.py

/Frontend
    /pages
        /templates
            template1.html
        /others
            404.html
            home.html

我更改了Flask模板文件夹的认位置:

app = Flask(__name__,template_folder="../Frontend/pages/")

认路由在这里

@app.route('/')
def default():
    return render_template("others/home.html")

和home.html包括

{% extends '../templates/template1.html' %}

错误消息如下:

jinja2.exceptions.TemplateNotFound: ../templates/template1.html 所以问题应该出在home.html引用不正确的template1.html,对吗?

我觉得我尝试了一切,甚至将template1.html放在与home.html相同的文件夹中,但这没用。

你知道这是怎么回事吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)