尝试使用该代码从“before_request”处理程序(在 Flask 中)中止会产生以下错误LookupError: no exception for 429
:有没有办法解决这个问题?
这是触发错误的代码:
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