Complete the code to import Flask and create an app instance.
from flask import [1] app = [1](__name__)
Flask is imported from the flask package and used to create the app instance.
Complete the code to define a route for the home page.
@app.route('[1]') def home(): return 'Hello, Flask!'
The root URL '/' is used to define the home page route in Flask.
Fix the error in the code to run the Flask app only when the script is executed directly.
if __name__ == [1]: app.run(debug=True)
The special variable __name__ equals '__main__' when the script is run directly.
Fill both blanks to access the HTTP method and return it in the response.
from flask import request @app.route('/method', methods=['GET', 'POST']) def method(): method_used = request.[1] return f'Method used: [2]'
request.method gives the HTTP method as a string. We store it in method_used and return it.
Fill all three blanks to extract a URL parameter and return a greeting.
@app.route('/hello/<[1]>') def hello([2]): return f'Hello, [3]!'
The URL parameter is named 'name'. The function argument must match it. The greeting uses that variable.