After looking for it for quite a while and asking on: https://gitter.im/timothycrosley/hug I'm unable to find a solution.
what I'm looking for is a way to return a custom http code, lets say 204 in case a condition is met in the get
end point.
the explanation for routing problems is here
but I can't seem to find a way to return any other codes other than 200 with a null response
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With