LEFT | RIGHT |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 # This Source Code is subject to the terms of the Mozilla Public License | 4 # This Source Code is subject to the terms of the Mozilla Public License |
5 # version 2.0 (the "License"). You can obtain a copy of the License at | 5 # version 2.0 (the "License"). You can obtain a copy of the License at |
6 # http://mozilla.org/MPL/2.0/. | 6 # http://mozilla.org/MPL/2.0/. |
7 | 7 |
8 import flask | 8 import flask |
9 from sitescripts.web import handlers | 9 from sitescripts.web import handlers |
10 from urlparse import urlparse | 10 from urlparse import urlparse |
11 | 11 |
12 app = flask.Flask(__name__) | 12 app = flask.Flask(__name__) |
13 | 13 |
14 @app.route("/<path:path>", methods = ["GET", "POST"]) | 14 @app.route("/<path:path>", methods = ["GET", "POST"]) |
15 def multiplex(path): | 15 def multiplex(path): |
16 request_url = urlparse(flask.request.url) | 16 request_url = urlparse(flask.request.url) |
17 request_path = request_url.path | 17 request_path = request_url.path |
18 if request_path in handlers: | 18 if request_path in handlers: |
19 if 'SERVER_ADDR' not in flask.request.environ: | 19 if 'SERVER_ADDR' not in flask.request.environ: |
20 flask.request.environ['SERVER_ADDR'] = flask.request.environ['SERVER_NAME'
] | 20 flask.request.environ['SERVER_ADDR'] = flask.request.environ['SERVER_NAME'
] |
21 return handlers[request_path] | 21 return handlers[request_path] |
22 return flask.abort(404) | 22 return flask.abort(404) |
23 | 23 |
24 if __name__ == "__main__": | 24 if __name__ == "__main__": |
25 app.run(debug=True) | 25 app.run(debug=True) |
LEFT | RIGHT |