在烧瓶中显示json和html模板

时间:2017-08-15 01:29:33

标签: python html json flask

如何在烧瓶中返回json以及下面的html模板?

@app.route('/test')
def test():
    a = {
    "test1": flag,
    "test2": flag
}
    return '''
       <body>
       ...
       </body>
       '''

1 个答案:

答案 0 :(得分:0)

@app.route('/test')
def test():
    a = {
    "test1": flag,
    "test2": flag
}
    b = jsonify(a)
    render_template("index.html",**locals())
  

在你的html文件中,你可以调用a,b等..

    

{{B}}

    

{{A}}