Thomas Abraham Thomas Abraham - 1 year ago 134
Python Question

How to check for the existence of a get parameter in flask

I'm new to python and flask.

I know that I can fetch a GET parameter with request.args.get(varname);. I wanted to check whether a GET request to my server is specifying and optional parameter or not.

Flask documentation didn't helped much.

Answer Source

You can actually use the default value,

opt_param = request.args.get("something")
if opt_param is None:
    print "Argument not provided"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download