Konstantin Rusanov
Konstantin Rusanov

Reputation: 6554

Flask request.args.get get all params (Python)

how i can parse all GET params from URL in flask? I tried use request.args.get, but it works with specific GET params (pre defined), but i need parse it all from my large URL (ex: http://site.ru/?a=1&b=2&c=3&some_string=string...)

Upvotes: 15

Views: 55711

Answers (2)

Ishan Tomar
Ishan Tomar

Reputation: 1554

[i for i in request.args.keys()]

Upvotes: 4

Mike
Mike

Reputation: 1735

If you use request.args it will provide a dictonary with key-value pairs of the GET parameters

Ex: http://website.com/index?arg1=hello&arg2=world

print request.args
>> {"arg1": "hello", "arg2": "world"}

The request.args.get(key) is a useful dictionary function that will return None if the parameter is not set rather than raising a KeyError

Upvotes: 36

Related Questions