0
0
Flaskframework~10 mins

Blueprint URL prefixes 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 register a blueprint with a URL prefix.

Flask
app.register_blueprint(admin_bp, url_prefix=[1])
Drag options to blanks, or click blank then click option'
A"dashboard"
B"admin"
C"/dashboard"
D"/admin"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the leading slash in the URL prefix.
2fill in blank
medium

Complete the code to define a blueprint with a name and import name.

Flask
admin_bp = Blueprint([1], __name__)
Drag options to blanks, or click blank then click option'
A"admin"
Badmin
C"Admin"
D"admin_bp"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without quotes instead of a string.
3fill in blank
hard

Fix the error in the route decorator to use the blueprint's URL prefix correctly.

Flask
@admin_bp.route([1])
def dashboard():
    return "Admin Dashboard"
Drag options to blanks, or click blank then click option'
A"dashboard/"
B"dashboard"
C"/admin/dashboard"
D"/dashboard"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the full path including the prefix.
4fill in blank
hard

Fill both blanks to create a blueprint and register it with a URL prefix.

Flask
admin_bp = Blueprint([1], __name__)
app.register_blueprint(admin_bp, url_prefix=[2])
Drag options to blanks, or click blank then click option'
A"admin"
B"/admin"
C"dashboard"
D"/dashboard"
Attempts:
3 left
💡 Hint
Common Mistakes
Using URL prefix without leading slash.
Using blueprint name with slash.
5fill in blank
hard

Fill all three blanks to define a blueprint, add a route, and register it with a URL prefix.

Flask
admin_bp = Blueprint([1], __name__)

@admin_bp.route([2])
def home():
    return "Welcome"

app.register_blueprint(admin_bp, url_prefix=[3])
Drag options to blanks, or click blank then click option'
A"admin"
B"/"
C"/admin"
D"home"
Attempts:
3 left
💡 Hint
Common Mistakes
Using route with the full prefix path.
Incorrect URL prefix format.