https://github.com/mosquito/aiohttp-compress
This module is the simplest way to enable compression support for aiohttp server applications globally.
https://github.com/mosquito/aiohttp-compress
aiohttp aiohttp-server asyncio deflate gzip
Last synced: 6 months ago
JSON representation
This module is the simplest way to enable compression support for aiohttp server applications globally.
- Host: GitHub
- URL: https://github.com/mosquito/aiohttp-compress
- Owner: mosquito
- License: apache-2.0
- Created: 2021-02-16T12:33:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-16T13:06:51.000Z (over 4 years ago)
- Last Synced: 2025-03-23T19:22:17.498Z (7 months ago)
- Topics: aiohttp, aiohttp-server, asyncio, deflate, gzip
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
aiohttp-compress
================[](https://pypi.org/project/aiohttp-compress) [](https://pypi.org/project/aiohttp-compress) [](https://pypi.org/project/aiohttp-compress) [](https://pypi.org/project/aiohttp-compress) [](https://coveralls.io/github/mosquito/aiohttp-compress?branch=master) 
This module is the simplest way to enable compression support for `aiohttp` server applications globally.
Installation
------------```bash
pip install aiohttp-compress
```Example
-------```python
from aiohttp import web
from aiohttp_compress import compress_middlewareasync def handle(request):
name = request.match_info.get(
'name', "Anonymous"
)
text = "Hello, " + name
return web.Response(text=text)app = web.Application()
app.middlewares.append(compress_middleware)
app.add_routes([
web.get('/', handle),
web.get('/{name}', handle)
])if __name__ == '__main__':
web.run_app(app)
```