0
0
Flaskframework~10 mins

HTML forms with POST method in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a form that sends data using POST method.

Flask
<form action="/submit" method="[1]">
  <input type="text" name="username">
  <button type="submit">Send</button>
</form>
Drag options to blanks, or click blank then click option'
APOST
BPUT
CGET
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for sending form data.
2fill in blank
medium

Complete the Flask route decorator to accept POST requests from the form.

Flask
@app.route('/submit', methods=["[1]"])
def submit():
    username = request.form['username']
    return f"Hello, {username}!"
Drag options to blanks, or click blank then click option'
APUT
BGET
CPOST
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to include POST in the methods list.
3fill in blank
hard

Fix the error in accessing form data in the Flask route.

Flask
def submit():
    username = request.[1]['username']
    return f"Hello, {username}!"
Drag options to blanks, or click blank then click option'
Aargs
Bform
Cjson
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using request.args to get POST form data.
4fill in blank
hard

Fill both blanks to create a form with a password input and submit button.

Flask
<form action="/login" method="[1]">
  <input type="[2]" name="password">
  <button type="submit">Login</button>
</form>
Drag options to blanks, or click blank then click option'
APOST
BGET
Cpassword
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET method for password forms.
Using input type text for passwords.
5fill in blank
hard

Fill all three blanks to handle POST form data and return a greeting in Flask.

Flask
@app.route('/greet', methods=["[1]"])
def greet():
    name = request.[2]['[3]']
    return f"Welcome, {name}!"
Drag options to blanks, or click blank then click option'
AGET
Bform
Cname
DPOST
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST in route methods.
Accessing form data incorrectly.
Using wrong field name.