Guest User

mlk

a guest
Jun 13th, 2008
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. js_mimetypes = frozenset(['text/javascript', 'application/x-javascript'])
  2.  
  3. def jsminify_middleware(app):
  4.     @webob_wrap
  5.     def middleware_app(req):
  6.         r = req.get_response(app)
  7.         if r.content_type in js_mimetypes and r.body:
  8.             r.decode_content()
  9.             r.body = jsmin(r.body)
  10.             if 'gzip' in req.accept_encoding:
  11.                 r.encode_content()            
  12.         return r
  13.     return middleware_app
  14.  
Advertisement
Add Comment
Please, Sign In to add comment