Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import Blueprint from Flask.
Flask
from flask import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Flask instead of Blueprint
Using render_template here
✗ Incorrect
Blueprint is imported from Flask to organize routes in large apps.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' or 'app' which are unrelated here
✗ Incorrect
The blueprint name 'auth' groups authentication routes.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'register' or 'add_blueprint' which don't exist
✗ Incorrect
The correct method to add a blueprint is register_blueprint.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing function name and route URL
Missing leading slash in route
✗ Incorrect
The route URL is '/login' and the function name is 'login'.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create_blueprint' which is not a Flask method
Mismatching blueprint variable and name
✗ Incorrect
We create a blueprint named 'admin_bp' with name 'admin' and register it using 'register_blueprint'.