/quart-compress

A package to compress responses in your Quart app with gzip

Primary LanguagePythonMIT LicenseMIT

Quart-Compress

Build Status codecov PyPI version Python Support black security: bandit

Description

Quart is a Python ASGI web microframework. It is intended to provide the easiest way to use asyncio functionality in a web context, especially with existing Flask apps. This is possible as the Quart API is a superset of the Flask API.

-- Quart Project

As I wanted to seamlessly migrate from Flask to Quart and noticed, that there are a few issues in using Flask-Compress together with Quart, I decided to create my own Quart-Compress packages, which is based on the Flask-Compress project.

Installation

Installing the package is as easy as:

$ pip install quart-compress2

Usage

To compress your Quart responses, you only need to compress your Quart object at the beginning using the Compress class:

from quart import Quart
from quart_compress import Compress

app = Quart(__name__)
Compress(app)

If you have to add a bunch of configuration to your application, you may need to instantiate the Compress object later using init_app:

from quart import Quart
from quart_compress import Compress

app = Quart(__name__)
compress = Compress()
# some more configurations
compress.init_app(app)