Bird
0
0

Which of the following is the correct way to apply a rate limit of 5 requests per minute to a Flask route using Flask-Limiter?

easy📝 Syntax Q12 of 15
Flask - Middleware and Extensions
Which of the following is the correct way to apply a rate limit of 5 requests per minute to a Flask route using Flask-Limiter?
A@limiter.limit('minute/5')\ndef my_route():\n return 'Hello'
B@limiter.limit(5)\ndef my_route():\n return 'Hello'
C@limiter.limit('5 requests')\ndef my_route():\n return 'Hello'
D@limiter.limit('5/minute')\ndef my_route():\n return 'Hello'
Step-by-Step Solution
Solution:
  1. Step 1: Check the syntax for rate limit string

    The correct format is a string like '5/minute' specifying count and time unit.
  2. Step 2: Validate each option's syntax

    @limiter.limit('5/minute')\ndef my_route():\n return 'Hello' uses '5/minute' which is correct. Options B, C, and D use incorrect formats or missing quotes.
  3. Final Answer:

    @limiter.limit('5/minute')\ndef my_route():\n return 'Hello' -> Option D
  4. Quick Check:

    Correct limit string format = @limiter.limit('5/minute')\ndef my_route():\n return 'Hello' [OK]
Quick Trick: Use string 'count/unit' like '5/minute' in @limiter.limit [OK]
Common Mistakes:
MISTAKES
  • Omitting quotes around the limit string
  • Using numbers without units
  • Incorrect time unit format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes