@bp.route('/dashboard') if the blueprint is registered with url_prefix='/admin'?from flask import Blueprint bp = Blueprint('admin', __name__, url_prefix='/admin') @bp.route('/dashboard') def dashboard(): return 'Admin Dashboard'
The url_prefix is prepended to all routes in the blueprint. So the route /dashboard becomes /admin/dashboard.
auth in a Flask app instance app?from flask import Flask, Blueprint app = Flask(__name__) auth = Blueprint('auth', __name__) # Registration code here
The register_blueprint method requires the blueprint object as the first argument. Option C correctly passes the blueprint and adds a URL prefix.
File structure: - app.py - auth.py (defines auth blueprint) - dashboard.py (defines dashboard blueprint) Both auth.py and dashboard.py import app.py and each other.
Delaying imports until after app creation or inside functions helps break circular import chains. This is a common best practice in Flask blueprint organization.
Blueprint('shop', __name__, template_folder='templates') and the app renders a template with render_template('index.html') inside a blueprint route, where does Flask look for index.html?shop = Blueprint('shop', __name__, template_folder='templates') @shop.route('/') def home(): return render_template('index.html')
When a blueprint has a template_folder set, Flask looks inside that folder relative to the blueprint's location for templates used in that blueprint's routes.
Registering blueprints inside the factory function allows creating multiple app instances with different settings and helps avoid circular import problems by delaying registration until app creation.