0
在某些情况下,我想呈现模板,而在其他情况下,我想提供模板文件。我通过了render_template
和send_file
的路径,但只有send_file
有效。render_template找不到模板,send_file可以
resp = render_template('templates/index.html')
resp = send_file('templates/index.html')
在某些情况下,我想呈现模板,而在其他情况下,我想提供模板文件。我通过了render_template
和send_file
的路径,但只有send_file
有效。render_template找不到模板,send_file可以
resp = render_template('templates/index.html')
resp = send_file('templates/index.html')
模板路径相对于模板根目录。 send_file
路径相对于应用程序根目录。
render_template('file.html')
send_file('templates/file.html')
除此之外,模板路径实际上并没有文件系统路径,它们只是碰巧看起来像他们在默认情况下,瓶。所以“模板根”真的意味着“模板加载器的查找路径”而不是“模板文件夹”。