Sending JSON and status code with a Flask response

Viewed 106621

I know I can set the status code of a response with Response(status=200). How can I return JSON data while setting the status code?

from flask import Flask, Response

@app.route('/login', methods=['POST'])
def login():
    response = Response(status=200)
    # need to set JSON like {'username': 'febin'}
    return response
2 Answers
Related