0
0
Flaskframework~10 mins

Rate limiting for protection in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Flask-Limiter extension.

Flask
from flask_limiter import [1]
Drag options to blanks, or click blank then click option'
ALimiter
BRateLimiter
CLimiterExtension
DFlaskLimiter
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like RateLimiter or FlaskLimiter.
Trying to import from wrong modules.
2fill in blank
medium

Complete the code to create a Limiter instance with default limits.

Flask
limiter = Limiter(app, default_limits=["[1] per minute"])
Drag options to blanks, or click blank then click option'
A10
B5
C100
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using too high a limit like 100 which is less protective.
Using invalid strings without 'per minute'.
3fill in blank
hard

Fix the error in the decorator to apply rate limiting on the route.

Flask
@limiter.[1]("3 per minute")
def home():
    return "Welcome!"
Drag options to blanks, or click blank then click option'
Alimit_rate
Brate_limit
Climit
Dlimiter
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect decorator names like rate_limit or limiter.
Misspelling the method name.
4fill in blank
hard

Fill both blanks to create a rate limit key function using IP address.

Flask
def [2]():
    return request.[1]

limiter = Limiter(app, key_func=[2])
Drag options to blanks, or click blank then click option'
Aremote_addr
Bip_address
Cclient_ip
Duser_ip
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names like ip_address or client_ip.
Passing wrong function names to key_func.
5fill in blank
hard

Fill all three blanks to create a custom error message for rate limit exceeded.

Flask
from flask import Flask, jsonify

@limiter.[1]("2 per minute")
def limited_route():
    return jsonify({"message": "[2]"}), [3]
Drag options to blanks, or click blank then click option'
Alimit
BToo many requests, slow down!
C429
Drate_limit
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong decorator names like rate_limit.
Using incorrect status codes like 400 or 500.
Not providing a clear error message.