Complete the code to create a Flask app instance.
from flask import Flask app = Flask([1])
The Flask app instance requires the current module name, which is given by __name__.
Complete the code to define a route for the home page.
@app.route([1]) def home(): return "Hello, Flask!"
The root URL path is "/" for the home page route.
Fix the error in the code to run the Flask app only when the script is executed directly.
if [1] == '__main__': app.run()
The special variable __name__ equals '__main__' when the script runs directly.
Fill both blanks to access the request method inside a route function.
from flask import [1] @app.route('/submit', methods=['POST']) def submit(): if [2].method == 'POST': return 'Form submitted!'
You import request from Flask and use it to check the HTTP method.
Fill all three blanks to create a context manager that pushes and pops the app context.
with app.[1]() as [2]: print([3].app.name)
The app_context() method creates a context manager. Capture the context variable as ctx and access the app name with ctx.app.name.