How to obtain values of parameters of get request in flask? How to obtain values of parameters of get request in flask? python python

How to obtain values of parameters of get request in flask?


The simple answer is you have not imported the request global object from the flask package.

from flask import Flask, request

This is easy to determine yourself by running the development server in debug mode by doing

app.run(debug=True)

This will give you a stacktrace including:

print request.args['x']NameError: global name 'request' is not defined


http://localhost:5000/api/iterators/opel/next?n=5

For something like the case before

from flask import Flask, requestn = request.args.get("n")

Can do the trick