Google News
logo
Flask - Interview Questions
How to get a query string in Flask?
The query string is a key/value pair that is sent by the client to the server in the web URL. These values are actually a part of the URL as a string of parameters and values. To get and work with the query string, we need to use the import request method from the flask.
//example of getting a query string in the Flask
from flask import request   //request method is used to work with the query string values
@app.route("/query")
def query():
args = request.args     //here, we get the query string object in a variable called ‘args’ using 
print(args)

 

Advertisement