【发布时间】:2016-09-17 02:43:31
【问题描述】:
由于GET 请求,我得到了一个响应对象,我已将其转换为JSON 和jsonify()。当我将它传递给模板时,我得到的只是一个 JSON 对象,例如:<Response 1366 bytes [200 OK]> this。
#request.py
...
response = requests.get('http://www.example.com')
response_json = jsonify(all=response.text)
return render_template(
'results.html',
form=ReqForm(request.form),
response=response_json,
date=datetime.datetime.now()
)
和模板..
#results.html
...
<div class="results">
{{ response }} # --> gives <Response 1366 bytes [200 OK]>
</div>
...
如何在模板中漂亮地显示这个 JSON?
【问题讨论】: