AFAIU `response['Content-Type'].startswith('text/html')` in `middleware.py` should be replaced with `'text/html' in response.get('Content-Type', '')`.