基本使用:
- 模板文件就是html文件,需要放在templates文件夹中。当然也可以在Flask(name,template_folder)来修改模板地址,但不推荐
- 通过render_template来渲染模板
- 传变量到模板中,可以把变量定义成字典,然后在render_template中,通过关键词参数的方式传递过去,render_template(’ ',**context)
返回渲染的模板后,可以在模板中用该字典中变量,通过{{ key }}
2023-11-22 13:21:28
基本使用: