January 2019
Beginner to intermediate
776 pages
19h 58m
English
Let us create a web server that serves contents after compressing it to the gzip format.
Listing 4.8 explains the HTTP compression as follows:
#!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - 4 # This program requires Python 3.5.2 or any later version # It may run on any other version with/without modifications. # # Follow the comments inline to make it run on Python 2.7.x. import argparse import string import os import sys import gzip import io # Comment out the above line and uncomment the below for Python 2.7.x. #import cStringIO from http.server import BaseHTTPRequestHandler, HTTPServer # Comment out the above line and uncomment the below for Python 2.7.x. #from BaseHTTPServer import BaseHTTPRequestHandler, ...
Read now
Unlock full access