How to handle missing parameters in URL with Flask/Python 3 [duplicate] How to handle missing parameters in URL with Flask/Python 3 [duplicate] flask flask

How to handle missing parameters in URL with Flask/Python 3 [duplicate]


The request.args.get() method allows to get the argument if it exists.

# return None if the argument doesn't existtrail = request.args.get('myTrail')# return 'x' if the argument doesn't existtrail = request.args.get('myTrail', 'x')

After this, just handle the value to return the way you want.