| OLD | NEW | 
|   1 #!/usr/bin/env python |   1 #!/usr/bin/env python | 
|   2 # coding: utf-8 |   2 # coding: utf-8 | 
|   3  |   3  | 
|   4 # This file is part of the Adblock Plus web scripts, |   4 # This file is part of the Adblock Plus web scripts, | 
|   5 # Copyright (C) 2006-2014 Eyeo GmbH |   5 # Copyright (C) 2006-2014 Eyeo GmbH | 
|   6 # |   6 # | 
|   7 # Adblock Plus is free software: you can redistribute it and/or modify |   7 # Adblock Plus is free software: you can redistribute it and/or modify | 
|   8 # it under the terms of the GNU General Public License version 3 as |   8 # it under the terms of the GNU General Public License version 3 as | 
|   9 # published by the Free Software Foundation. |   9 # published by the Free Software Foundation. | 
|  10 # |  10 # | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  22  |  22  | 
|  23 from sitescripts.web import handlers |  23 from sitescripts.web import handlers | 
|  24  |  24  | 
|  25 class MultiplexerApp: |  25 class MultiplexerApp: | 
|  26   def __call__(self, environ, start_response): |  26   def __call__(self, environ, start_response): | 
|  27     if 'REQUEST_URI' in environ: |  27     if 'REQUEST_URI' in environ: | 
|  28       request = urlparse(environ['REQUEST_URI']) |  28       request = urlparse(environ['REQUEST_URI']) | 
|  29       if request.path in handlers: |  29       if request.path in handlers: | 
|  30         return handlers[request.path](environ, start_response) |  30         return handlers[request.path](environ, start_response) | 
|  31  |  31  | 
 |  32       request_dir = re.sub(r'[^/]+$', '', request.path) | 
 |  33       if request_dir in handlers: | 
 |  34         return handlers[request_dir](environ, start_response) | 
 |  35  | 
|  32     start_response('404 Not Found', [('Content-Type', 'text/html')]) |  36     start_response('404 Not Found', [('Content-Type', 'text/html')]) | 
|  33     return ["Not Found"] |  37     return ["Not Found"] | 
|  34  |  38  | 
|  35 bindAddress = None |  39 bindAddress = None | 
|  36 if 'FCGI_BIND_ADDRESS' in os.environ: |  40 if 'FCGI_BIND_ADDRESS' in os.environ: | 
|  37   match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS']) |  41   match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS']) | 
|  38   bindAddress = (match.group(1), int(match.group(2))) |  42   bindAddress = (match.group(1), int(match.group(2))) | 
|  39 srv = WSGIServer(MultiplexerApp(), debug=False, bindAddress=bindAddress) |  43 srv = WSGIServer(MultiplexerApp(), debug=False, bindAddress=bindAddress) | 
|  40  |  44  | 
|  41 if __name__ == '__main__': |  45 if __name__ == '__main__': | 
|  42   srv.run() |  46   srv.run() | 
|  43  |  47  | 
| OLD | NEW |