Bird
0
0

Given this Flask app snippet using Flask-Limiter:

medium📝 component behavior Q13 of 15
Flask - Middleware and Extensions
Given this Flask app snippet using Flask-Limiter:
from flask import Flask
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

app = Flask(__name__)
limiter = Limiter(app, key_func=get_remote_address)

@app.route('/')
@limiter.limit('2/minute')
def home():
    return 'Welcome!'

# Assume the same client makes 3 quick requests
What will happen on the third request from the same client within one minute?
AThe third request will be blocked with a 429 Too Many Requests error
BThe third request will succeed and return 'Welcome!'
CThe app will crash with an exception
DThe third request will be delayed but eventually succeed
Step-by-Step Solution
Solution:
  1. Step 1: Understand the limit set

    The route is limited to 2 requests per minute per client IP.
  2. Step 2: Analyze the third request behavior

    The third request exceeds the limit, so Flask-Limiter blocks it with a 429 error.
  3. Final Answer:

    The third request will be blocked with a 429 Too Many Requests error -> Option A
  4. Quick Check:

    Requests > limit = 429 error [OK]
Quick Trick: Requests over limit get 429 error response [OK]
Common Mistakes:
MISTAKES
  • Thinking extra requests succeed silently
  • Assuming app crashes on limit exceed
  • Believing requests get delayed instead of blocked

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes