Sometimes, we want to access the query string in Python Flask routes.
In this article, we’ll look at how to access the query string in Python Flask routes.
How to access the query string in Python Flask routes?
To access the query string in Python Flask routes, 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 access the query string in Python Flask routes, we can use the request.args
property.