烧瓶:带有路径的render_template [英] Flask: render_template with path

查看:276
本文介绍了烧瓶:带有路径的render_template的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个要用于我的烧瓶应用程序的模板.

I have several different templates that I'm trying to use for my flask app.

我尝试了以下操作,但它似乎只能直接在/templates内部查看,而不能直接在/templates/folder1,templates/folder2等内部查看.

I have tried the following but it seems to only look directly inside /templates and not /templates/folder1, templates/folder2 etc.

 return render_template('index.html', template_folder='folder1')
 return render_template('folder1/index.html')

两者均无法正常工作,如何指定不同模板的子文件夹.

both do not work as expected, how can I specify the sub folder of different templates.

推荐答案

我认为Sean是正确的,但是:您是否尝试过使用双引号?我使用的是蓝图,所以可能有所不同,但这就是我的样子:

I think Sean is right, but also: have you tried double quotes? I'm using Blueprint, so it may be different, but this is what mine looks like:

return render_template("users/register.html")

所以你可能是:

return render_template("folder1/index.html")

这篇关于烧瓶:带有路径的render_template的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆