Recall & Review
beginner
What is the purpose of static files in a Flask Blueprint?
Static files are resources like images, CSS, and JavaScript that do not change dynamically. In a Flask Blueprint, static files allow you to organize these resources separately for each part of your app.
Click to reveal answer
beginner
How do you specify a folder for static files in a Flask Blueprint?
When creating a Blueprint, you use the 'static_folder' parameter to tell Flask where to find the static files for that Blueprint.
Click to reveal answer
intermediate
What URL path prefix does Flask use by default for Blueprint static files?
By default, Flask serves Blueprint static files under '/<blueprint_name>/static/'. For example, if the Blueprint is named 'admin', static files are accessed at '/admin/static/'.
Click to reveal answer
beginner
How can you link to a Blueprint's static file in a Jinja2 template?
Use the 'url_for' function with the format 'url_for("<blueprint_name>.static", filename="file_name")'. This generates the correct URL to the static file inside the Blueprint.
Click to reveal answer
intermediate
Can multiple Blueprints have their own static folders in Flask?
Yes, each Blueprint can have its own static folder. This helps keep static files organized by feature or section of the app.
Click to reveal answer
How do you tell Flask where a Blueprint's static files are located?
✗ Incorrect
The 'static_folder' parameter in the Blueprint constructor specifies the folder for static files.
What URL path does Flask use to serve static files from a Blueprint named 'shop' by default?
✗ Incorrect
Flask serves Blueprint static files under '//static/', so for 'shop' it is '/shop/static/'.
Which function helps you generate the URL for a Blueprint's static file in a template?
✗ Incorrect
Use url_for with the Blueprint name and 'static' endpoint to get the correct URL.
Can two Blueprints share the same static folder in Flask?
✗ Incorrect
While possible, sharing static folders can cause confusion and is not recommended.
What is the benefit of having static files inside a Blueprint?
✗ Incorrect
Organizing static files inside Blueprints keeps your project tidy and modular.
Explain how to serve static files from a Flask Blueprint and how to link to them in templates.
Think about how Flask knows where the files are and how templates find them.
You got /3 concepts.
Describe the advantages of organizing static files within Blueprints in a Flask app.
Consider how large projects benefit from modular structure.
You got /3 concepts.