Complete the code to create a Flask blueprint with a static folder named 'static'.
from flask import Blueprint bp = Blueprint('main', __name__, static_folder=[1])
The static_folder parameter defines the folder name for static files in the blueprint. It is usually named 'static'.
Complete the code to register the blueprint with the Flask app and serve static files under the URL prefix '/main'.
from flask import Flask app = Flask(__name__) app.register_blueprint(bp, url_prefix=[1])
The url_prefix sets the URL path prefix for all routes and static files in the blueprint. Here, '/main' is used.
Fix the error in the blueprint static file URL generation code.
from flask import url_for static_url = url_for('[1].static', filename='style.css')
To generate the URL for a static file in a blueprint, use the blueprint's name followed by '.static'. Here, the blueprint is named 'main'.
Fill both blanks to define a route in the blueprint that serves a static file URL for 'logo.png'.
from flask import Blueprint, url_for bp = Blueprint('assets', __name__, static_folder='static') @bp.route('/logo') def logo(): return url_for('[1].static', filename=[2])
The blueprint is named 'assets', so use 'assets.static' to get the static file URL. The filename is 'logo.png'.
Fill all three blanks to create a blueprint with a static folder, register it with a URL prefix, and generate a static file URL.
from flask import Flask, Blueprint, url_for bp = Blueprint('files', __name__, static_folder=[1]) app = Flask(__name__) app.register_blueprint(bp, url_prefix=[2]) static_url = url_for('[3].static', filename='image.png')
The static folder is named 'static'. The blueprint is registered with the prefix '/files'. The blueprint's name 'files' is used to generate the static file URL.