Performance: Response object creation
MEDIUM IMPACT
This affects server response time and how quickly the browser receives and renders content.
def view(): return 'Hello World', 200, {'Content-Type': 'text/plain'}
from flask import Response def view(): data = 'Hello World' resp = Response(data) resp.headers['Content-Type'] = 'text/plain' return resp
| Pattern | Server Processing | Response Size | Network Delay | Verdict |
|---|---|---|---|---|
| Manual Response object creation | Higher (extra object creation) | Same | Same | [!] OK |
| Return tuple with data and headers | Lower (direct return) | Same | Same | [OK] Good |