Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
Getting even better everyday

BeastImran BeastImran

:electron:
Getting even better everyday
View GitHub Profile
View Python_gzip_response.py
import gzip
from io import BytesIO as IO
def send_response(request, response):
accept_encoding = request.headers.get("Accept-Encoding", "") or request.headers.get("accept-encoding", "")
if ("gzip" not in accept_encoding.lower()) or (response.status < 200 or response.status >= 300 or "Content-Encoding" in response.headers):
return response