Skip to content

Commit

Permalink
Use minified json instead of gzip in compress_response
Browse files Browse the repository at this point in the history
  • Loading branch information
Kishan Patel authored and ksp37-dluhc committed Jun 14, 2024
1 parent 099e9b5 commit 1ff1e69
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/routes/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import gzip
import json
from uuid import UUID

Expand All @@ -16,10 +15,10 @@ def default(self, obj):
return obj.hex
return json.JSONEncoder.default(self, obj)

content = gzip.compress(json.dumps(data, cls=UUIDEncoder).encode("utf8"), 5)
content = json.dumps(data, cls=UUIDEncoder, separators=(",", ":"))
response = make_response(content)
response.headers["Content-length"] = len(content)
response.headers["Content-Encoding"] = "gzip"
response.headers["Content-Type"] = "application/json"
return response


Expand Down

0 comments on commit 1ff1e69

Please sign in to comment.