1

Trying to abort from a "before_request" handler (in Flask) with that code gives the following error: LookupError: no exception for 429. Is there a way to fix this?

Here's the code that triggers the error:

key = "ip:{}:account-requests".format(request.remote_addr)

# Determine how many requests have been made in the past day
# by this API.
requests_made = r.get(key) or 0

if requests_made >= max_requests:
    abort(429) #HTTP Too Many Requests
Te-jé Rodgers
  • 878
  • 1
  • 7
  • 20

1 Answers1

4

you can do like this in Flask

if requests_made >= max_requests:
    return '429 error', 429
linnchord
  • 130
  • 2
  • 7