| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 4 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
| 14 # | 14 # |
| 15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
| 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 17 | 17 |
| 18 import sys, os, flask | 18 import sys, os, flask |
| 19 from ...utils import setupStderr | |
| 20 from ..utils import process_page | 19 from ..utils import process_page |
| 21 from ..sources import FileSource | 20 from ..sources import FileSource |
| 22 from ..converters import converters | 21 from ..converters import converters |
| 23 | 22 |
| 24 app = flask.Flask("sitescripts.cms.bin.test_server") | 23 app = flask.Flask("cms.bin.test_server") |
| 25 source = None | 24 source = None |
| 26 | 25 |
| 27 mime_types = { | 26 mime_types = { |
| 28 "": "text/html; charset=utf-8", | 27 "": "text/html; charset=utf-8", |
| 29 ".htm": "text/html; charset=utf-8", | 28 ".htm": "text/html; charset=utf-8", |
| 30 ".html": "text/html; charset=utf-8", | 29 ".html": "text/html; charset=utf-8", |
| 31 ".js": "application/javascript; charset=utf-8", | 30 ".js": "application/javascript; charset=utf-8", |
| 32 ".css": "text/css; charset=utf-8", | 31 ".css": "text/css; charset=utf-8", |
| 33 ".xml": "text/xml; charset=utf-8", | 32 ".xml": "text/xml; charset=utf-8", |
| 34 ".png": "image/png", | 33 ".png": "image/png", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 def show(path=""): | 59 def show(path=""): |
| 61 data = get_data(path) | 60 data = get_data(path) |
| 62 if data == None: | 61 if data == None: |
| 63 flask.abort(404) | 62 flask.abort(404) |
| 64 | 63 |
| 65 root, ext = os.path.splitext(path) | 64 root, ext = os.path.splitext(path) |
| 66 mime = mime_types.get(ext.lower(), "application/octet-stream") | 65 mime = mime_types.get(ext.lower(), "application/octet-stream") |
| 67 return data, 200, {"Content-Type": mime} | 66 return data, 200, {"Content-Type": mime} |
| 68 | 67 |
| 69 if __name__ == "__main__": | 68 if __name__ == "__main__": |
| 70 setupStderr() | |
| 71 if len(sys.argv) < 2: | 69 if len(sys.argv) < 2: |
| 72 print >>sys.stderr, "Usage: %s source_dir" % sys.argv[0] | 70 print >>sys.stderr, "Usage: %s source_dir" % sys.argv[0] |
| 73 sys.exit(1) | 71 sys.exit(1) |
| 74 | 72 |
| 75 source = FileSource(sys.argv[1]) | 73 source = FileSource(sys.argv[1]) |
| 76 | 74 |
| 77 # Make sure to "fix" argv to ensure that restart can succeed | 75 # Make sure to "fix" argv to ensure that restart can succeed |
| 78 sys.argv[0:1] = ["-m", "sitescripts.cms.bin.test_server"] | 76 sys.argv[0:1] = ["-m", "cms.bin.test_server"] |
| 79 | 77 |
| 80 app.run(debug=True) | 78 app.run(debug=True) |
| OLD | NEW |