Recall & Review
beginner
What is Flask-Limiter used for in a Flask application?
Flask-Limiter is used to control how many times a user or client can access certain routes in a Flask app within a set time. It helps prevent too many requests, protecting the app from overload or abuse.
Click to reveal answer
beginner
How do you apply a simple rate limit of 5 requests per minute to a Flask route using Flask-Limiter?
You decorate the route with @limiter.limit('5 per minute'). This tells Flask-Limiter to allow only 5 requests to that route every minute from the same client.
Click to reveal answer
intermediate
What is the default key used by Flask-Limiter to identify clients for rate limiting?
By default, Flask-Limiter uses the client's IP address to track and limit requests.
Click to reveal answer
advanced
How can you customize the key function in Flask-Limiter to use user ID instead of IP address?
You can pass a custom key function to Flask-Limiter that returns the user ID from the request context, so limits apply per user rather than per IP.
Click to reveal answer
beginner
What happens when a client exceeds the rate limit set by Flask-Limiter?
Flask-Limiter returns a 429 Too Many Requests HTTP response, telling the client to slow down and try again later.
Click to reveal answer
Which decorator applies a rate limit of 10 requests per hour to a Flask route?
✗ Incorrect
The correct syntax is @limiter.limit('10 per hour'). Other options are invalid.
What default client identifier does Flask-Limiter use to track request counts?
✗ Incorrect
Flask-Limiter uses the client's IP address by default to identify and limit requests.
What HTTP status code does Flask-Limiter return when a client exceeds the rate limit?
✗ Incorrect
429 Too Many Requests is the standard response when rate limits are exceeded.
How can you apply different rate limits to different routes in Flask-Limiter?
✗ Incorrect
You apply @limiter.limit with specific limits on each route to customize rate limits.
Which of these is NOT a valid rate limit string for Flask-Limiter?
✗ Incorrect
'10 requests per minute' is invalid because the word 'requests' should not be included in the string.
Explain how Flask-Limiter helps protect a Flask app and how you set a basic rate limit on a route.
Think about stopping too many requests from one user.
You got /3 concepts.
Describe how Flask-Limiter identifies clients by default and how you might change this behavior.
Consider what makes each user unique.
You got /2 concepts.