Skip to content

Commit

Permalink
Add a pre-commit file (#47)
Browse files Browse the repository at this point in the history
* Add a pre-commit file

This resolves failing pre-commit.ci runs caused by this missing file.

* Run `pre-commit run -a`
  • Loading branch information
kurtmckee authored Sep 24, 2024
1 parent cf54b23 commit 53edb18
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ci:
autoupdate_schedule: "quarterly"

default_language_version:
python: "python3.12"

exclude: "tests/templates/"

repos:
- repo: "meta"
hooks:
- id: "check-hooks-apply"
- id: "check-useless-excludes"

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.6.0"
hooks:
- id: "check-added-large-files"
- id: "check-merge-conflict"
- id: "check-yaml"
- id: "end-of-file-fixer"
- id: "mixed-line-ending"
args:
- "--fix=lf"
- id: "trailing-whitespace"

- repo: "https://github.com/python-jsonschema/check-jsonschema"
rev: "0.29.2"
hooks:
- id: "check-github-workflows"

- repo: "https://github.com/rhysd/actionlint"
rev: "v1.7.1"
hooks:
- id: "actionlint"
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ The preferred solution is to have a server (like [Nginx](http://wiki.nginx.org/M

## How it works

Flask-Compress both adds the various headers required for a compressed response and compresses the response data.
Flask-Compress both adds the various headers required for a compressed response and compresses the response data.
This makes serving 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 whether the client and the server use some common compression algorithm, and will automatically attach the
and whether the client and the server use some common compression algorithm, and will automatically attach the
appropriate headers.

To determine the compression algorithm, the `Accept-Encoding` request header is inspected, respecting the
quality factor as described in [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding).
quality factor as described in [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding).
If no requested compression algorithm is supported by the server, we don't compress the response. If, on the other
hand, multiple suitable algorithms are found and are requested with the same quality factor, we choose the first one
defined in the `COMPRESS_ALGORITHM` option (see below).
defined in the `COMPRESS_ALGORITHM` option (see below).


## Installation
Expand Down Expand Up @@ -98,8 +98,8 @@ def view():

### Cache example

Flask-Compress can be integrated with caching mechanisms to serve compressed responses directly from the cache. This can significantly reduce server load and response times.
Here is an example of how to configure Flask-Compress with caching using Flask-Caching.
Flask-Compress can be integrated with caching mechanisms to serve compressed responses directly from the cache. This can significantly reduce server load and response times.
Here is an example of how to configure Flask-Compress with caching using Flask-Caching.
The example demonstrates how to create a simple cache instance with a 1-hour timeout, and use it to cache compressed responses for incoming requests.

```python
Expand Down

0 comments on commit 53edb18

Please sign in to comment.