Pranav Kulkarni

Python Tips: Getting Data from a Flask Request

To retrieve data received in a Flask request, you can use the following attributes available on the request object:

from flask import request

All of these attributes are instances of MultiDict from the Werkzeug library, except for json. To access values from the MultiDict, you can use the following methods:

In most common cases, request.data will be empty as it is used as a fallback when Flask encounters a mime-type it doesn't handle.

For more details, you can refer to the Flask documentation on the request object.