All Projects → subyraman → sanic_compress

subyraman / sanic_compress

Licence: other
An extension which allows you to easily compress your Sanic responses with gzip.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to sanic compress

Tinydeflate
A deflate/gzip decompressor that requires minimal amount of memory to work
Stars: ✭ 148 (+469.23%)
Mutual labels:  compression, gzip
Turbobench
Compression Benchmark
Stars: ✭ 211 (+711.54%)
Mutual labels:  compression, gzip
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+511.54%)
Mutual labels:  compression, gzip
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (+80.77%)
Mutual labels:  compression, gzip
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-38.46%)
Mutual labels:  compression, gzip
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+5273.08%)
Mutual labels:  compression, gzip
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (+634.62%)
Mutual labels:  compression, gzip
Genozip
Compressor for genomic files (FASTQ, SAM/BAM, VCF, FASTA, GVF, 23andMe...), up to 5x better than gzip and faster too
Stars: ✭ 53 (+103.85%)
Mutual labels:  compression, gzip
gzipped
Replacement for golang http.FileServer which supports precompressed static assets.
Stars: ✭ 86 (+230.77%)
Mutual labels:  compression, gzip
em inflate
Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
Stars: ✭ 59 (+126.92%)
Mutual labels:  compression, gzip
Fastify Compress
Fastify compression utils
Stars: ✭ 95 (+265.38%)
Mutual labels:  compression, gzip
zlib
Compression and decompression in the gzip and zlib formats
Stars: ✭ 32 (+23.08%)
Mutual labels:  compression, gzip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+238.46%)
Mutual labels:  compression, gzip
Gzip
💾 Golang gzip middleware for Gin and net/http | Golang gzip中间件,支持Gin和net/http,开箱即用同时可定制
Stars: ✭ 113 (+334.62%)
Mutual labels:  compression, gzip
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (+207.69%)
Mutual labels:  compression, gzip
Uzlib
Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Stars: ✭ 168 (+546.15%)
Mutual labels:  compression, gzip
Zoonavigator
Web-based ZooKeeper UI / editor / browser
Stars: ✭ 326 (+1153.85%)
Mutual labels:  compression, gzip
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+2569.23%)
Mutual labels:  compression, gzip
Compression
Node.js compression middleware
Stars: ✭ 2,506 (+9538.46%)
Mutual labels:  compression, gzip
hasmin
Hasmin - A Haskell CSS Minifier
Stars: ✭ 55 (+111.54%)
Mutual labels:  compression, gzip

sanic_compress

sanic_compress is an extension which allows you to easily gzip your Sanic responses. It is a port of the Flask-Compress extension.

Installation

Install with pip:

pip install sanic_compress

Usage

Usage is simple. Simply pass in the Sanic app object to the Compress class, and responses will be gzipped.

from sanic import Sanic
from sanic_compress import Compress

app = Sanic(__name__)
Compress(app)

Options

Within the Sanic application config you can provide the following settings to control the behavior of sanic_compress. None of the settings are required.

COMPRESS_MIMETYPES: Set the list of mimetypes to compress here.

  • Default: {'text/html','text/css','text/xml','application/json','application/javascript'}

COMPRESS_LEVEL: Specifies the gzip compression level (1-9).

  • Default: 6

COMPRESS_MIN_SIZE: Specifies the minimum size (in bytes) threshold for compressing responses.

  • Default: 500

A higher COMPRESS_LEVEL will result in a gzipped response that is smaller, but the compression will take longer.

Example of using custom configuration:

from sanic import Sanic
from sanic_compress import Compress

app = Sanic(__name__)
app.config['COMPRESS_MIMETYPES'] = {'text/html', 'application/json'}
app.config['COMPRESS_LEVEL'] = 4
app.config['COMPRESS_MIN_SIZE'] = 300
Compress(app)

Note about gzipping static files:

Sanic is not at heart a file server. You should consider serving static files with nginx or on a separate file server.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].