Home > Mobile >  Return response message alongside of code in Flask
Return response message alongside of code in Flask

Time:12-01

I am currently sending a JSON response on endpoint trigger. My current app looks something like below.

@app.route('/run', methods = ['POST', 'GET'])
def run():
    ...
    response_dict = {"item1":"...", "item2":"..."}
    return make_response(jsonify(response_dict), 200)

Now I wanted to send a response comment alongside with code, for example, make_response(jsonify(response_dict), 200, response_message="data not processed for item5")

Is this possible?

CodePudding user response:

I think there is no such thing as a "Response Comment". One thing you can do is to add a message field to your response JSON, with the message you want to send.

  • Related