python hug api return custom http code
Found an example in their repo (https://github.com/berdario/hug/blob/5470661c6f171f1e9da609c3bf67ece21cf6d6eb/examples/return_400.py)
import hug
from falcon import HTTP_400
@hug.get()
def only_positive(positive: int, response):
if positive < 0:
response.status = HTTP_400
You can raise the falcon HTTPError, for example:
raise HTTPInternalServerError
see more details: https://falcon.readthedocs.io/en/stable/api/errors.html