Recall & Review
beginner
What is the purpose of a login form in a Flask web application?
A login form collects user credentials like username and password to verify the user's identity before granting access to protected parts of the website.
Click to reveal answer
beginner
Which Flask extension is commonly used to manage user sessions and authentication?
Flask-Login is a popular extension that helps manage user sessions, handle login/logout, and protect routes that require authentication.
Click to reveal answer
intermediate
In Flask, how do you securely check if a user's password is correct?
You use password hashing functions like Werkzeug's generate_password_hash to store hashed passwords and check_password_hash to verify the entered password against the stored hash.
Click to reveal answer
beginner
What is the role of the @app.route decorator in creating a login form?
The @app.route decorator defines the URL endpoint for the login page and specifies which HTTP methods (GET, POST) the function will handle to display the form and process login data.
Click to reveal answer
beginner
Why should you use POST method instead of GET for submitting login forms?
POST hides the submitted data in the request body, making it more secure than GET, which appends data to the URL and can expose sensitive information like passwords.
Click to reveal answer
Which Flask function helps you protect routes so only logged-in users can access them?
✗ Incorrect
The @login_required decorator from Flask-Login restricts access to routes to only authenticated users.
What does the function check_password_hash() do in Flask?
✗ Incorrect
check_password_hash() compares a plain password with a stored hashed password to verify if they match.
Which HTTP method should be used to submit login credentials securely?
✗ Incorrect
POST sends data in the request body, keeping credentials hidden from the URL, unlike GET.
What is the main purpose of Flask-Login?
✗ Incorrect
Flask-Login helps manage user login states and session handling.
Where do you define the URL path for the login page in Flask?
✗ Incorrect
The @app.route decorator sets the URL endpoint for the login view function.
Explain how to create a simple login form in Flask and verify user credentials.
Think about the steps from showing the form to logging the user in.
You got /5 concepts.
Describe why password hashing is important in login verification and how Flask supports it.
Consider what happens if someone steals your password database.
You got /5 concepts.