Data Handling Using the Request Object
In this lesson, we will handle the POST request received by the login template and retrieve the data from it.
📌 How can we know if a particular request is
GET
orPOST
?
This is where therequest
object comes in handy. Let’s find out more about therequest
object.
Accessing form data
To access the data sent by a user, we use the global request
object. Before we start using it, let’s import it from the flask
module.
from flask import request
Getting the Method
type from request
We can use the method
member variable of the request
object to determine the method of an incoming request.
Consider the snippet given below.
Get hands-on with 1400+ tech skills courses.