0
0
Flaskframework~10 mins

Why blueprints organize large applications in Flask - Test Your Understanding

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

Complete the code to import Blueprint from Flask.

Flask
from flask import [1]
Drag options to blanks, or click blank then click option'
Arequest
BFlask
Crender_template
DBlueprint
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Flask instead of Blueprint
Using render_template here
2fill in blank
medium

Complete the code to create a new blueprint named 'auth'.

Flask
auth_bp = Blueprint('[1]', __name__)
Drag options to blanks, or click blank then click option'
Aauth
Buser
Capp
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' or 'app' which are unrelated here
3fill in blank
hard

Fix the error in registering the blueprint to the Flask app.

Flask
app.[1](auth_bp, url_prefix='/auth')
Drag options to blanks, or click blank then click option'
Aregister_blueprint
Badd_blueprint
Cregister
Dinclude_blueprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'register' or 'add_blueprint' which don't exist
4fill in blank
hard

Fill both blanks to define a route inside a blueprint.

Flask
@auth_bp.route('[1]')
def [2]():
    return 'Login Page'
Drag options to blanks, or click blank then click option'
A/login
Blogin
C/logout
Dlogout
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing function name and route URL
Missing leading slash in route
5fill in blank
hard

Fill all three blanks to create and register a blueprint with a URL prefix.

Flask
from flask import Blueprint

[1] = Blueprint('[2]', __name__)
app.[3]([1], url_prefix='/admin')
Drag options to blanks, or click blank then click option'
Aadmin_bp
Badmin
Cregister_blueprint
Dcreate_blueprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create_blueprint' which is not a Flask method
Mismatching blueprint variable and name