James W.
—You want to access the data passed into your Flask application, but when attempting to access the data using request.data
, you found that sometimes the data returned is an empty string that does not represent the data you are trying to access.
The request
module allows you to access the data passed into your Flask application through an HTTP request.
The data within a request can be accessed through the request
module’s properties.
These properties allow for data to be stored in the many different forms that data can be received through HTTP requests, like: query strings, form data, cookies, and more.
The .data
property should only be used in circumstances where the data passed into your Flask application comes with a mimetype that Flask does not handle.
Otherwise you should use the request
property that reflects the type of the data you are trying to access.
Make sure to use the request
property that best suits your data.
Here are some request
properties for common data types:
request.arg
accesses the query string (the URL parameters) and returns the key/value pairs.
request.form
accesses form data and returns the form parameters (if the form uploads a file however, use request.files
to access the file data).
request.cookies
returns a dictionary with the cookies associated with the request.
request.json
returns parsed JSON data if the mimetype
is JSON.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.