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 Adblock Plus <http://adblockplus.org/>, | 4 # This file is part of Adblock Plus <http://adblockplus.org/>, |
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 20 matching lines...) Expand all Loading... |
31 def multiplex(path=""): | 31 def multiplex(path=""): |
32 request_url = urlparse(flask.request.url) | 32 request_url = urlparse(flask.request.url) |
33 request_path = request_url.path | 33 request_path = request_url.path |
34 if request_path.startswith("/lib/"): | 34 if request_path.startswith("/lib/"): |
35 path = flask.safe_join(os.path.dirname(__file__), request_path.lstrip("/")) | 35 path = flask.safe_join(os.path.dirname(__file__), request_path.lstrip("/")) |
36 if not os.path.isfile(path): | 36 if not os.path.isfile(path): |
37 return flask.abort(404) | 37 return flask.abort(404) |
38 | 38 |
39 with open(path, "rb") as file: | 39 with open(path, "rb") as file: |
40 module = os.path.splitext(request_path[len("/lib/"):])[0] | 40 module = os.path.splitext(request_path[len("/lib/"):])[0] |
41 data = "require.scopes['%s'] = function(){exports={};%s\nreturn exports;}(
);" % (module, file.read()) | 41 data = "require.scopes['%s'] = function(){var exports={};%s\nreturn export
s;}();" % (module, file.read()) |
42 return (data, 200, {"Content-Type": "application/javascript; charset=utf-8
"}) | 42 return (data, 200, {"Content-Type": "application/javascript; charset=utf-8
"}) |
43 else: | 43 else: |
44 if request_path.endswith("/"): | 44 if request_path.endswith("/"): |
45 request_path += "index.html" | 45 request_path += "index.html" |
46 return flask.send_from_directory(os.path.join(os.path.dirname(__file__), "te
st"), request_path.lstrip("/")) | 46 return flask.send_from_directory(os.path.join(os.path.dirname(__file__), "te
st"), request_path.lstrip("/")) |
47 | 47 |
48 if __name__ == "__main__": | 48 if __name__ == "__main__": |
49 app.run(debug=True) | 49 app.run(debug=True) |
OLD | NEW |