Bird
0
0

Identify the issue in this middleware snippet:

medium📝 Debug Q6 of 15
Flask - Middleware and Extensions
Identify the issue in this middleware snippet:
class FaultyMiddleware:
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):
        response = self.app(environ)
        return response

app.wsgi_app = FaultyMiddleware(app.wsgi_app)
AThe wrapped app is called without start_response argument
BThe __call__ method should not return anything
CThe __init__ method is missing required parameters
DMiddleware should not wrap app.wsgi_app
Step-by-Step Solution
Solution:
  1. Step 1: Check __call__ Signature

    WSGI app call requires both environ and start_response.
  2. Step 2: Identify Error

    Here, self.app(environ) misses start_response, causing a TypeError.
  3. Final Answer:

    The wrapped app is called without start_response argument -> Option A
  4. Quick Check:

    WSGI call must include start_response [OK]
Quick Trick: Always pass start_response to wrapped app call [OK]
Common Mistakes:
MISTAKES
  • Omitting start_response argument
  • Returning None instead of response iterable
  • Misunderstanding WSGI call signature

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes