我知道烧瓶功能render_template
。我必须给出模板的文件名。但现在我想渲染模板的字符串(即模板的内容)。这就说得通了。但我现在不想解释原因。如何简单地渲染模板的文本?
您可以使用render_template_string http://flask.pocoo.org/docs/1.0/api/#flask.render_template_string:
>>> from flask import render_template_string
>>> render_template_string('hello {{ what }}', what='world')
'hello world'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)