| OLD | NEW | 
|---|
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, | 
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH | 
| 3 # | 3 # | 
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify | 
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as | 
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. | 
| 7 # | 7 # | 
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, | 
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. | 
| 12 # | 12 # | 
| 13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License | 
| 14 # along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 15 | 15 | 
| 16 import mimetypes | 16 import mimetypes | 
| 17 import os | 17 import os | 
| 18 import sys | 18 import sys | 
| 19 import argparse | 19 import argparse | 
| 20 | 20 | 
| 21 import jinja2 | 21 import jinja2 | 
| 22 | 22 | 
| 23 from cms.utils import process_page | 23 from cms.utils import process_page | 
| 24 from cms.sources import FileSource | 24 from cms.sources import create_source | 
| 25 from cms.converters import converters | 25 from cms.converters import converters | 
| 26 | 26 | 
| 27 source = None | 27 source = None | 
| 28 address = None | 28 address = None | 
| 29 port = None | 29 port = None | 
| 30 | 30 | 
| 31 UNICODE_ENCODING = 'utf-8' | 31 UNICODE_ENCODING = 'utf-8' | 
| 32 | 32 | 
| 33 ERROR_TEMPLATE = ''' | 33 ERROR_TEMPLATE = ''' | 
| 34 <html> | 34 <html> | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 121     return [data] | 121     return [data] | 
| 122 | 122 | 
| 123 if __name__ == '__main__': | 123 if __name__ == '__main__': | 
| 124 | 124 | 
| 125     parser = argparse.ArgumentParser(description='CMS development server created
      to test pages locally and on-the-fly') | 125     parser = argparse.ArgumentParser(description='CMS development server created
      to test pages locally and on-the-fly') | 
| 126     parser.add_argument('path', nargs='?', default=os.curdir) | 126     parser.add_argument('path', nargs='?', default=os.curdir) | 
| 127     parser.add_argument('-a', '--address', default='localhost', help='Address of
      the interface the server will listen on') | 127     parser.add_argument('-a', '--address', default='localhost', help='Address of
      the interface the server will listen on') | 
| 128     parser.add_argument('-p', '--port', type=int, default=5000, help='TCP port t
     he server will listen on') | 128     parser.add_argument('-p', '--port', type=int, default=5000, help='TCP port t
     he server will listen on') | 
| 129     args = parser.parse_args() | 129     args = parser.parse_args() | 
| 130 | 130 | 
| 131     source = FileSource(args.path) | 131     source = create_source(args.path) | 
| 132     address = args.address | 132     address = args.address | 
| 133     port = args.port | 133     port = args.port | 
| 134 | 134 | 
| 135     try: | 135     try: | 
| 136         from werkzeug.serving import ThreadedWSGIServer, run_simple | 136         from werkzeug.serving import ThreadedWSGIServer, run_simple | 
| 137 | 137 | 
| 138         # see https://github.com/mitsuhiko/werkzeug/pull/770 | 138         # see https://github.com/mitsuhiko/werkzeug/pull/770 | 
| 139         ThreadedWSGIServer.daemon_threads = True | 139         ThreadedWSGIServer.daemon_threads = True | 
| 140 | 140 | 
| 141         def run(*args, **kwargs): | 141         def run(*args, **kwargs): | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 162                     return app(environ, start_response) | 162                     return app(environ, start_response) | 
| 163                 except Exception as e: | 163                 except Exception as e: | 
| 164                     return show_error(start_response, '500 Internal Server Error
     ', | 164                     return show_error(start_response, '500 Internal Server Error
     ', | 
| 165                                       uri=environ.get('PATH_INFO'), error=e) | 165                                       uri=environ.get('PATH_INFO'), error=e) | 
| 166 | 166 | 
| 167             server = make_server(host, port, wrapper, ThreadedWSGIServer) | 167             server = make_server(host, port, wrapper, ThreadedWSGIServer) | 
| 168             print ' * Running on http://%s:%i/' % server.server_address | 168             print ' * Running on http://%s:%i/' % server.server_address | 
| 169             server.serve_forever() | 169             server.serve_forever() | 
| 170 | 170 | 
| 171     run(address, port, handler, use_reloader=True, use_debugger=True) | 171     run(address, port, handler, use_reloader=True, use_debugger=True) | 
| OLD | NEW | 
|---|