Sometimes, we want to access the query string in Flask routes with Python.
In this article, we’ll look at how to access the query string in Flask routes with Python.
How to access the query string in Flask routes with Python?
To access the query string in Flask routes with Python, we can use the request.query_string
property.
For instance, we write
from flask import request
@app.route('/adhoc_test/')
def adhoc_test():
return request.query_string
to get the query string with request.query_string
within the adhoc_test
view.
We use request.args.get('param')
to get the value of the param
query string parameter.
Conclusion
To access the query string in Flask routes with Python, we can use the request.query_string
property.