def compress(self, data): zipBuffer = StringIO.StringIO() zipFile =
def compress(self, data): zipBuffer = StringIO.StringIO() zipFile = gzip.GzipFile(mode = wb , fileobj = zipBuffer, compresslevel = 6) zipFile.write(data) zipFile.close() zipped = zipBuffer.getvalue() zipBuffer.close() self.content_length = len(zipped) return zipped Note that you will need to import the StringIO and gzip packages to use this method. It is trivial to add a call to this method on the data being served, but you also have to set up the code to check whether the client accepts gzipped data, and also return appropriate HTTP response codes not so trivial. You need to add code to look for a header in the HTTP request that will look something like this: Accept-Encoding: gzip Before compressing and returning the data, the server should add a header that looks like this: Content-Encoding: gzip Don t be afraid to insert lots of print statements to see what s happening in both the client and server code. 235 Systematic Overview
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.