Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added djng.middleware.GZip and example of applying that middleware to…

… just one path within a site
  • Loading branch information...
commit 77d7b7c20b8a0561b4741ef777915376db8dbb0d 1 parent 63afa89
Simon Willison authored
1  djng/__init__.py
@@ -3,6 +3,7 @@
3 3 settings.configure(USE_18N = False)
4 4 del settings
5 5
  6 +import middleware
6 7 from django.conf.urls.defaults import url
7 8 from router import Router
8 9 from errors import ErrorWrapper
5 djng/middleware.py
... ... @@ -0,0 +1,5 @@
  1 +from django.utils.decorators import decorator_from_middleware
  2 +from django.middleware.gzip import GZipMiddleware
  3 +
  4 +GZip = decorator_from_middleware(GZipMiddleware)
  5 +del GZipMiddleware
15 example_middleware.py
... ... @@ -0,0 +1,15 @@
  1 +import djng
  2 +
  3 +def hello(request):
  4 + return djng.Response('Hello, world ' * 100)
  5 +
  6 +def goodbye(request):
  7 + return djng.Response('Goodbye, world ' * 100)
  8 +
  9 +app = djng.Router(
  10 + (r'^hello$', hello),
  11 + (r'^goodbye$', djng.middleware.GZip(goodbye)),
  12 +)
  13 +
  14 +if __name__ == '__main__':
  15 + djng.serve(app, '0.0.0.0', 8888)

0 comments on commit 77d7b7c

Please sign in to comment.
Something went wrong with that request. Please try again.