Bird
0
0

Given this Flask test code snippet, what will response.status_code be after a successful login?

medium📝 component behavior Q13 of 15
Flask - Testing Flask Applications
Given this Flask test code snippet, what will response.status_code be after a successful login?
response = client.post('/login', data={'username': 'user', 'password': 'pass'}, follow_redirects=True)
A200
B302
C404
D500
Step-by-Step Solution
Solution:
  1. Step 1: Understand follow_redirects=True effect

    Setting follow_redirects=True makes the client follow redirects and return the final page response.
  2. Step 2: Determine status code after successful login with redirect

    After login, the app redirects (302) but client follows it, so final response is the redirected page with status 200.
  3. Final Answer:

    200 -> Option A
  4. Quick Check:

    follow_redirects=True means final status = 200 [OK]
Quick Trick: follow_redirects=True returns final page status 200 [OK]
Common Mistakes:
MISTAKES
  • Expecting 302 instead of 200 when following redirects
  • Confusing 404 or 500 as login response codes
  • Ignoring follow_redirects parameter effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes