Complete the code to define the Flask application factory function.
from flask import Flask def create_app(): app = Flask(__name__) return [1]
The function must return the Flask app instance named app.
Complete the code to register a blueprint inside the application factory.
from flask import Flask, Blueprint bp = Blueprint('main', __name__) def create_app(): app = Flask(__name__) app.[1](bp) return app
add_url_rule instead of register_blueprint.run inside the factory.Use register_blueprint to add a blueprint to the Flask app.
Fix the error in the application factory by completing the code to load configuration from a file.
def create_app(): app = Flask(__name__) app.config.[1]('config.py') return app
load_config.The correct method to load config from a file is from_pyfile.
Fill both blanks to create a route inside a blueprint and return a greeting.
from flask import Blueprint bp = Blueprint('main', __name__) @bp.route([1]) def hello(): return [2]
"/home" when root is expected.The route decorator needs the path "/" and the function returns the greeting string "Hello, Flask!".
Fill all three blanks to create an application factory that registers a blueprint and loads config.
from flask import Flask, Blueprint bp = Blueprint('main', __name__) @bp.route("/") def index(): return "Welcome!" def create_app(): app = Flask(__name__) app.config.[1]('config.py') app.[2](bp) return [3]
The factory loads config with from_pyfile, registers the blueprint with register_blueprint, and returns the app instance.