Skip to content

Instantly share code, notes, and snippets.

Getting even better everyday

BeastImran BeastImran

Getting even better everyday
View GitHub Profile
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