Skip to content

Commit

Permalink
feat: compress server response
Browse files Browse the repository at this point in the history
  • Loading branch information
whelmich committed Aug 28, 2023
1 parent 1ddaa74 commit 98e4532
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Flask==2.0.2
flask-compress==1.13
joblib==1.1.0
numpy==1.25.2
pandas==1.3.5
Expand Down
7 changes: 7 additions & 0 deletions docker/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
from flask import request
from flask import jsonify as flask_jsonify
from flask import Response
from flask_compress import Compress

# import numpy as np
# import numpy.random as rand

app = flask.Flask(__name__)

# compress all server responses with gzip, deflate or brotli
# for large responses this results in ±90% reduction (62.5MB -> 5.5MB)
# at a cost of ±15% response time (4.5s -> 5.2s)
Compress(app)

# !!! comment out for production !!!
# app.config["DEBUG"] = True

Expand Down

0 comments on commit 98e4532

Please sign in to comment.