Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊFastAPI ProductionModule 4 Β· Production patterns Β· Recapβ€ΊπŸŽ― Review: FastAPI module 4 recapscenario85 / 105
+80 XP
Task
Build a small `rate_limited(user_id, requests_per_minute, current_rpm)` that returns the HTTP status code you'd send: 1. `current_rpm < requests_per_minute` β†’ `200` (allowed). 2. `current_rpm >= requests_per_minute` β†’ `429` (Too Many Requests). 3. `user_id` starting with `"admin_"` is exempt β€” always `200`. 4. `requests_per_minute <= 0` is a misconfiguration β€” return `503` (Service Unavailable) so the caller sees a config bug, not a silent block.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…