I have a function that analyzes a CSV file with Pandas and produces a dict with summary information. I want to return the results as a response from a Flask view. How do I r
Pass keyword arguments to flask.jsonify and they will be output as a JSON object.
@app.route('/_get_current_user')
def get_current_user():
return jsonify(
username=g.user.username,
email=g.user.email,
id=g.user.id
)
{
"username": "admin",
"email": "admin@localhost",
"id": 42
}
If you already have a dict, you can pass it directly as jsonify(d)
.