You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flask's request class stores information about the HTTP request being made to the server per request. request.args returns an ImmutableMultiDict which can be accessed like a normal dict.
Example:
# URL: /api/user?uuid=1request.args["uuid"]
>>>1
When the key trying to be accessed doesn't exist, a BadRequestKeyError. This can be resolved many ways, two of which include:
Trying this access in a try/catch loop, catching the BadRequestKeyError
try:
ifrequest.args["uuid"]:
# Do some stuff.exceptBadRequestKeyError:
return {"message": "No UUID was provided."}, 422
Using the in keyword to test the existence, returning false if the key doesn't exist.
if"uuid"inrequest.args:
# Do some stuff.else:
return {"message": "No UUID was provided."}, 422
Flask's request class stores information about the HTTP request being made to the server per request.
request.args
returns an ImmutableMultiDict which can be accessed like a normal dict.Example:
When the key trying to be accessed doesn't exist, a BadRequestKeyError. This can be resolved many ways, two of which include:
in
keyword to test the existence, returning false if the key doesn't exist.HTTP Code 422
A way forward needs to be agreed upon and the API code needs to be updated for consistency.
The text was updated successfully, but these errors were encountered: