I'm writing a Flask+SQLAlchemy app to replace a series of PHP scripts that were developed a long time ago. One of the scripts depends on a number of keys being available on the $_GET
variable, like appName. These values are sent by an external app that I cannot control.
What is the best way to capture the key/value pairs set on $_GET from Flask?
All you really need to do is examine the request
object. To extract a variable called "foo" from the request, you would run something similar to this:
request.args.get('foo', '');
This will return the value of the foo
parameter, and if it doesn't exist it will return a default empty string (the second parameter to the get
function).
Here is the relevant documentation: