0
0
Flaskframework~10 mins

Password reset email pattern 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 import the Flask mail extension.

Flask
from flask_mail import [1]
Drag options to blanks, or click blank then click option'
AMail
BEmail
CMessage
DSendMail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Email' instead of 'Mail' causes import errors.
Confusing 'Message' with the mail handler class.
2fill in blank
medium

Complete the code to create a Flask-Mail message with subject and recipient.

Flask
msg = Message(subject='Password Reset', recipients=[[1]])
Drag options to blanks, or click blank then click option'
Auser
B'user@example.com'
Cuser_email
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable without quotes causes errors if not defined.
Passing a user object instead of an email string.
3fill in blank
hard

Fix the error in sending the email with Flask-Mail instance named 'mail'.

Flask
mail.[1](msg)
Drag options to blanks, or click blank then click option'
Asend
Bsend_message
Cdeliver
Ddispatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send_message' causes attribute errors.
Using 'deliver' or 'dispatch' are not valid Flask-Mail methods.
4fill in blank
hard

Fill both blanks to create a token URL for password reset with Flask's url_for.

Flask
reset_url = url_for('[1]', token=[2], _external=True)
Drag options to blanks, or click blank then click option'
Areset_password
Btoken
Creset
Duser_token
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong endpoint names like 'reset' or 'user_token'.
Using incorrect parameter names.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension filtering users with active status.

Flask
active_users = {user.id: user.email for user in users if user.[1] == [2] and user.[3]
Drag options to blanks, or click blank then click option'
Astatus
B'active'
Cis_verified
Dis_admin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is_admin' instead of 'is_verified' changes the filter logic.
Comparing status to wrong string values.