
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Quart-Compress allows you to easily compress your Quart application's responses with gzip.
The preferred solution is to have a server (like Nginx) automatically compress the static files for you. If you don't have that option Quart-Compress will solve the problem for you.
Quart-Compress both adds the various headers required for a compressed response and gzips the response data. This makes serving gzip compressed static files extremely easy.
Internally, every time a request is made the extension will check if it matches one of the compressible MIME types and will automatically attach the appropriate headers.
If you use pip then installation is simply:
$ pip install quart-compress
or, if you want the latest github version:
$ pip install git+git://github.com/AceFire6/quart-compress.git
Quart-Compress is incredibly simple to use. In order to start gzip'ing your Quart application's assets, the first thing to do is let Quart-Compress know about your quart.Quart
application object.
from quart import Quart
from quart_compress import Compress
app = Quart(__name__)
Compress(app)
In many cases, however, one cannot expect a Quart instance to be ready at import time, and a common pattern is to return a Quart instance from within a function only after other configuration details have been taken care of. In these cases, Quart-Compress provides a simple function, quart_compress.Compress.init_app
, which takes your application as an argument.
from quart import Quart
from quart_compress import Compress
compress = Compress()
def start_app():
app = Quart(__name__)
compress.init_app(app)
return app
In terms of automatically compressing your assets using gzip, passing your quart.Quart
object to the quart_compress.Compress
object is all that needs to be done.
Within your Quart application's settings you can provide the following settings to control the behavior of Quart-Compress. None of the settings are required.
Option | Description | Default |
---|---|---|
COMPRESS_MIMETYPES | Set the list of mimetypes to compress here. | [ 'text/html', 'text/css', 'text/xml', 'application/json', 'application/javascript' ] |
COMPRESS_LEVEL | Specifies the gzip compression level. | 6 |
COMPRESS_MIN_SIZE | Specifies the minimum file size threshold for compressing files. | 500 |
COMPRESS_CACHE_KEY | Specifies the cache key method for lookup/storage of response data. | None |
COMPRESS_CACHE_BACKEND | Specified the backend for storing the cached response data. | None |
COMPRESS_REGISTER | Specifies if compression should be automatically registered. | True |
FAQs
Compress responses in your Quart app with gzip or brotli.
We found that quart-compress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.