Sometimes, we want to get the named parameters from a URL using Python Flask
In this article, we’ll look at how to get the named parameters from a URL using Python Flask.
How to get the named parameters from a URL using Python Flask?
To get the named parameters from a URL using Python Flask, we can use the request.args
property.
For instance, we write
from flask import request
@app.route('/login')
def login():
username = request.args.get('username')
password = request.args.get('password')
to call request.args.get
with the keys of the query parameters we want to get in our view function.
Conclusion
To get the named parameters from a URL using Python Flask, we can use the request.args
property.