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, making the app easier to manage.
Click to reveal answer
beginner
How do you create a Blueprint in Flask?
You create a Blueprint by importing Blueprint from flask and then making an instance with a name and import name, like: <br><code>from flask import Blueprint<br>bp = Blueprint('bp_name', __name__)</code>Click to reveal answer
beginner
How do you register a Blueprint to a Flask app?
You register a Blueprint by calling
app.register_blueprint() and passing the Blueprint instance. This connects the Blueprint routes to the main app.Click to reveal answer
intermediate
Why use Blueprints in a Flask app?
Blueprints help keep code organized, allow reuse of code parts, and make it easier to work in teams by separating features into modules.
Click to reveal answer
beginner
What happens if you forget to register a Blueprint in Flask?
If you forget to register a Blueprint, its routes won’t be available in the app. It’s like writing a chapter but never adding it to the book — users can’t see it.
Click to reveal answer
What is the first step to use a Blueprint in Flask?
✗ Incorrect
You first create a Blueprint instance before you can register it or use it.
Which method connects a Blueprint to the main Flask app?
✗ Incorrect
The correct method is app.register_blueprint() to add the Blueprint routes to the app.
What argument is required when creating a Blueprint?
✗ Incorrect
You must provide a name and the import name (usually __name__) when creating a Blueprint.
What is a benefit of using Blueprints in Flask?
✗ Incorrect
Blueprints help organize code into smaller, manageable modules.
If a Blueprint is not registered, what happens?
✗ Incorrect
Without registration, the Blueprint routes won’t be part of the app.
Explain how to create and register a Blueprint in Flask step-by-step.
Think about setting up a mini app and then connecting it to the main app.
You got /4 concepts.
Describe why using Blueprints can help when building larger Flask applications.
Imagine building a big house by working on rooms separately.
You got /4 concepts.