I'm having a little trouble using the flask.jsonify function to output a formatted json response from a dictionary input, as described in here.
My code is seems to be returning the Response object, instead of the formatted json object that I want.
I have
@app.route('/rparser', methods=['GET', 'POST'])
def rparser():
form = ParserForm(request.form)
if request.method=='POST':
result = jsonify(**dict)
return render_template('rparser.html', form=form, result=result)
else:
return render_template('rparser.html', form=form)
where dict is a dictionary object returned from calling a function.
And in my template, I have:
(form up here)
{% if result %}
{{ result }}
{% endif %}
This is displaying:
Response 135 bytes [200 OK]
How would I make this return the json representation that I am looking for?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…