Flask Request Object - HTTP method used


In Flask, the request object provides information about the request being processed in the view functions.

For example, the request object provides the HTTP method used.

👇

from flask import request

@users_blueprint.route('/register', methods=['GET', 'POST'])
def register():
    if request.method == 'POST':
        # Validate request
        return '<p>New user registered!</p>'

    return '<h2>Registration Form</h2>'