Recall & Review
beginner
What is a Blueprint in Flask?
A Blueprint in Flask is a way to organize a group of related routes and functions. It helps split a large app into smaller parts, like chapters in a book.
Click to reveal answer
beginner
What does the URL prefix do when registering a Blueprint?
The URL prefix adds a starting path to all routes inside the Blueprint. For example, if the prefix is '/admin', all Blueprint routes start with '/admin'.
Click to reveal answer
beginner
How do you register a Blueprint with a URL prefix in Flask?
Use app.register_blueprint(blueprint, url_prefix='/prefix'). This tells Flask to add '/prefix' before all Blueprint routes.
Click to reveal answer
intermediate
Why use URL prefixes with Blueprints?
URL prefixes help group routes logically and avoid conflicts. For example, '/user' prefix for user pages and '/admin' for admin pages.
Click to reveal answer
intermediate
What happens if you register two Blueprints with the same URL prefix?
Flask will combine their routes under the same prefix. If routes inside conflict, Flask raises an error. So, route paths inside Blueprints should be unique.
Click to reveal answer
What is the purpose of the url_prefix parameter when registering a Blueprint?
✗ Incorrect
The url_prefix adds a common path before all routes in the Blueprint, grouping them under that prefix.
If a Blueprint has a route '/dashboard' and is registered with url_prefix='/admin', what is the full URL path?
✗ Incorrect
The url_prefix '/admin' is added before the Blueprint route '/dashboard', making the full path '/admin/dashboard'.
Can you register multiple Blueprints with different url_prefix values in the same Flask app?
✗ Incorrect
You can register many Blueprints, each with its own url_prefix to organize routes.
What happens if you register a Blueprint without specifying url_prefix?
✗ Incorrect
Without url_prefix, Blueprint routes are registered directly at the root URL level.
Why is it important to avoid route name conflicts inside Blueprints sharing the same url_prefix?
✗ Incorrect
If routes inside Blueprints with the same url_prefix have the same path, Flask raises an error due to conflicts.
Explain how URL prefixes work with Flask Blueprints and why they are useful.
Think about how you group pages under sections in a website.
You got /4 concepts.
Describe the steps to register a Blueprint with a URL prefix in a Flask app.
Focus on how you connect the Blueprint to the main app.
You got /4 concepts.