Flask,如何将字符串响应为html?

时间:2016-12-27 14:29:40

标签: python html flask

我想编写代码来处理用户发布的数据,并返回一个字符串类型值并显示它的页面,这里是我的演示代码

def model(...):
    ...
    strs = process(...)
    return render_template('page.html' ...)

我该怎么做?

1 个答案:

答案 0 :(得分:3)

您是否希望在strs模板中传递page.html?你应该看一下烧瓶的official tutorial来掌握基础知识。

def model(...):
    ...
    strs = process(...)
    return render_template('page.html', string_variable=strs)

模板page.html可以将strs引用为string_variable

<p>This is the processed string: {{ string_variable }} </p>