How to throw an exception if url query string spelling is wrong?
Explanation :
this is the url to get particular user:
http://127.0.0.1:5000/v1/t/user/?user_id=1
.
if endures will hit http://127.0.0.1:5000/v1/t/user/
it will give list of users.
Question:
what if user_id
spelling is wrong in query string ,like by mistake use_id=1
, or instead of passing integer value, string value is passing to user_id
I hope in this case I should return 404 page. I don't think internally request.args.get()
will throw? if I have to handle this scenarios how to do?
Some part of my code:
page_index = request.args.get('index', 1, type=int)
max_item = request.args.get('max', 1, type=int)
userID = request.args.get('user_id', type=int)