From 2998b5a95526f268e3b6dd7039a8a82258553924 Mon Sep 17 00:00:00 2001 From: UltraQbik Date: Sat, 24 Aug 2024 22:58:13 +0300 Subject: Don't compress what is already compressed --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 75f9064..8760d15 100644 --- a/main.py +++ b/main.py @@ -208,12 +208,17 @@ class HTTPServer: data = minimize_html(data) if request.type == "GET": - return Response(data, STATUS_CODE_OK) + response = Response(data, STATUS_CODE_OK) elif request.type == "HEAD": - return Response(b'', STATUS_CODE_OK, {"Content-Length": len(data)}) + response = Response(b'', STATUS_CODE_OK, {"Content-Length": len(data)}) else: raise TypeError("Called GET handler for non-GET request") + if filepath[-4:] == "webp": + response.compress = False + + return response + elif len(split_path) >= 2 and split_path[0] in API_VERSIONS: # assume script # unsupported API version if not API_VERSIONS[split_path[0]]: -- cgit 1.4.1