在某些情况下,我希望呈现一个模板,而在另一些情况下,我希望提供模板文件。我通过了通往render_template和send_file的相同路径,但只有send_file工作。
resp = render_template('templates/index.html')
resp = send_file('templates/index.html')发布于 2017-06-14 16:22:27
模板路径相对于模板根。send_file路径相对于应用程序根。
render_template('file.html')
send_file('templates/file.html')另外,模板路径实际上并不是文件系统路径,它们恰好在默认的烧瓶中看起来就像它们。所以“模板根”实际上意味着“模板加载程序的查找路径”而不是“模板文件夹”。
https://stackoverflow.com/questions/44549502
复制相似问题