Python 带html模板的Flask变量动态url

Python 带html模板的Flask变量动态url,python,flask,Python,Flask,在编写一些代码以动态更新页面时。我遇到了它试图渲染页面的问题。 错误是: jinja2.exceptions.TemplateNotFound:/html/test.html 这是查找和呈现页面的代码: # Open the user file to read from url = name url_file = open('projects.txt', 'r') lines = url_file.readlines()

在编写一些代码以动态更新页面时。我遇到了它试图渲染页面的问题。 错误是:

jinja2.exceptions.TemplateNotFound:/html/test.html

这是查找和呈现页面的代码:

        # Open the user file to read from
        url = name
        url_file = open('projects.txt', 'r')
        lines = url_file.readlines()
        # check all lines for matching name
        for line in lines:
            saved_url, maintance, html = line.split("|")
            if saved_url == url:  # if url is the same. print info and display page. adding maintence check after
                print("url:", saved_url, " is in maintence:", maintance, " html template area:", html),
                if maintance == 'false':
                    return render_template(html)
不确定是什么原因导致此错误,或者flask只是不喜欢读取模板位置的变量

模板确实存在。通过使用/html/index.html尝试这个方法,可以实现这一点。 注意:代码的其余部分可以工作。就在最后一行

我知道使用任何类型的数据库都会更好,但目前我必须在其中工作

编辑 因此,代码读取的是projects.txt中的
test | false |/html/test.html
。 运行调试时,变量html以字符串形式读取。它的读数是
/html/test.html
。 关键是,它应该作为一个字符串从该字符串传递


我将在html中为这些项目创建一个动态更新区域,因为我原来的想法似乎行不通。

嗨,欢迎来到StackOverflow!看起来您正在尝试呈现文件
test.html
,该文件不存在或不在Flask查找它的位置(即在目录
html
)抱歉,我忘记添加了。test.html确实存在。当使用/html/index.html作为替代时,它确实起到了作用。
返回render\u template(html)
-什么是html?能否发布一个存储在html变量中的字符串示例?甚至projects.txt
return render_template('test.html')
-html文件名作为字符串而不是对象传递给render_template