Complete the code to get the value of 'username' from the form data.
username = request.form.get([1])The request.form.get() method expects the form field name as a string. So, you need to pass 'username' as a string.
Complete the code to import the Flask request object.
from flask import [1]
You need to import request from Flask to access form data inside routes.
Fix the error in the route to correctly access form data for 'email'.
@app.route('/submit', methods=['POST']) def submit(): email = request.[1]['email'] return f"Email: {email}"
form.get() with parentheses after form causes an error.get as an attribute incorrectly.You should access request.form as a dictionary to get the value by key. Using request.form['email'] is correct.
Fill both blanks to create a route that handles POST requests and retrieves 'password' from form data.
@app.route('/login', methods=[[1]]) def login(): password = request.form.get([2]) return f"Password: {password}"
The route must accept POST requests, so 'POST' is used in methods. To get the password from form data, pass the string 'password' to request.form.get().
Fill all three blanks to create a route that accepts POST, retrieves 'email' and 'name' from form data, and returns a greeting.
@app.route('/greet', methods=[[1]]) def greet(): email = request.form.get([2]) name = request.form.get([3]) return f"Hello, {name}! Your email is {email}."
The route must accept POST requests, so 'POST' is used in methods. To get the email and name from form data, pass the strings 'email' and 'name' respectively to request.form.get().