Category: security

Problem

Simple in-memory rate limiter.

Solution

  if len(requests_log[key]) >= limit:
    raise HTTPException(429)
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path