July 2017
Beginner to intermediate
340 pages
7h 43m
English
The first simple thing you can do to reduce the bandwidth is to use GZIP compression, so everything that is sent over the wire gets smaller. Web servers such as Apache or nginx provide native support to compress responses on the fly, and it's better to avoid implementing your ad hoc compression at the Python level.
For example, this nginx configuration will enable GZIP compression for any response produced by the Flask app on port 5000, with an application/json content type:
http { gzip on; gzip_types application/json; gzip_proxied any; gzip_vary on; server { listen 80; server_name localhost; location / { proxy_pass http://localhost:5000; } }
From the client-side, making an HTTP request to the nginx server ...