0
I have the following code in my application in Flask:
from flask import request, json
cpf = request.json['cpf']
It works normally, but when there is no attribute in the json request it displays the error:
builtins.Keyerror
Keyerror: 'cnpj_cpf'
And for the execution, my doubt is how I can handle this request to be able to launch a Answer with code 400 (Bad Request) saying that the Cpf attribute is missing, without this "coding error"
Thank you very much, it worked 100% here, that’s what I needed!
– Vengi