google.appengine.ext.zipserve package

Summary

This is a solution for apps that want to serve 1000s of small static
files while staying withing the 1000 file limit.

The simplest use case is driven purely from the handlers section in
app.yaml, e.g.:

url: /images/.*
script: $PYTHON_LIB/google/appengine/ext/zipserve

This would invoke a main() within zipserve/__init__.py. This code
would then take the URL path, and look for a .zip file under the first
component of the path, in this case “images.zip” in the app’s working
directory. If found, it will then serve any matching paths below that
from the zip file. In other words, /images/foo/icon.gif would map to
foo/icon.gif in the zip file images.zip.

You can also customize the behavior by adding a custom line to your
WSGIApplication() invocation:

def main():

app = webapp.WSGIApplication(

[(‘/’, MainPage),

(‘/static/(.*)’, zipserve.make_zip_handler(‘staticfiles.zip’)),

])

You can pass max_age=N to the make_zip_handler() call to override the
expiration time in seconds, which defaults to 600.

To customize the behavior even more, you can subclass ZipHandler and
override the get() method, or override it and call ServeFromZipFile()
directly.

Note that by default, a Cache-control is added that makes these pages
cacheable even if they require authentication. If this is not what
you want, override ZipHandler.SetCachingHeaders().