0
0
Flaskframework~5 mins

Request object properties in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the Flask request object used for?
The request object in Flask holds all the information about the current HTTP request, like form data, query parameters, headers, and more.
Click to reveal answer
beginner
How do you access form data sent via POST in Flask?
Use request.form to get form data sent in a POST request. It acts like a dictionary with form field names as keys.
Click to reveal answer
beginner
What property of request gives you URL query parameters?
request.args contains the URL query parameters as a dictionary-like object.
Click to reveal answer
beginner
How can you get the HTTP method (GET, POST, etc.) of the current request?
Use request.method to find out the HTTP method used for the request.
Click to reveal answer
intermediate
What property would you use to access JSON data sent in a request?
Use request.get_json() to get JSON data sent in the request body. It returns a Python dictionary if JSON is valid.
Click to reveal answer
Which request property holds form data sent via POST?
Arequest.args
Brequest.json
Crequest.data
Drequest.form
How do you get the HTTP method of the current request in Flask?
Arequest.type
Brequest.method
Crequest.action
Drequest.mode
Which property contains URL query parameters?
Arequest.args
Brequest.form
Crequest.query
Drequest.params
To access JSON data sent in a request body, you use:
Arequest.body
Brequest.data
Crequest.json
Drequest.form
Which request property gives you access to raw request data?
Arequest.data
Brequest.args
Crequest.form
Drequest.json
Explain how to access form data, query parameters, and JSON data from a Flask request object.
Think about where each type of data is sent in an HTTP request.
You got /3 concepts.
    Describe how to determine the HTTP method of a request in Flask and why it might be useful.
    Consider how web forms and APIs behave differently with GET and POST.
    You got /3 concepts.