diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-22 03:00:37 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-22 03:00:37 +0300 |
| commit | eedb57f893986091887d1a889d6752ea4b06ba2a (patch) | |
| tree | 92aee69db8d6dba0e3b42341c8b40553c7ced851 /main.py | |
| parent | 76ac2995b1c460f852816a3271fc7777d12b632d (diff) | |
| download | httpy-eedb57f893986091887d1a889d6752ea4b06ba2a.tar.gz httpy-eedb57f893986091887d1a889d6752ea4b06ba2a.zip | |
Add simple HTML minimizer for gooder compression
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/main.py b/main.py index e85e536..f22b957 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ import signal import asyncio import aiofiles from src.request import Request +from src.minimizer import minimize_html # path mapping @@ -168,6 +169,10 @@ class HTTPServer: async with aiofiles.open(PATH_MAP[request.path]["path"], "rb") as f: data = await f.read() + # pre-compress data for HTML files + if PATH_MAP[request.path]["path"][-4:] == "html": + data = minimize_html(data) + # add gzip compression header (if supported) headers = {} if "gzip" in compressions: |