Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: multiplexer.py

Issue 6209629180657664: Issue 2169 - Unify development and production implementation of multiplexer (Closed)
Patch Set: Created March 23, 2015, 4:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « multiplexer.fcgi ('k') | sitescripts/web.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: multiplexer.py
===================================================================
--- a/multiplexer.py
+++ b/multiplexer.py
@@ -16,28 +16,17 @@
# You should have received a copy of the GNU General Public License
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
-import re
-import flask
-from sitescripts.web import handlers
-from urlparse import urlparse
+from sitescripts.web import multiplex
-app = flask.Flask(__name__)
+try:
+ from werkzeug.serving import run_simple
+except ImportError:
+ from wsgiref.simple_server import make_server
-@app.route("/<path:path>", methods = ["GET", "POST"])
-def multiplex(path):
- request_url = urlparse(flask.request.url)
- if 'SERVER_ADDR' not in flask.request.environ:
- flask.request.environ['SERVER_ADDR'] = flask.request.environ['SERVER_NAME']
- if 'REQUEST_URI' not in flask.request.environ:
- flask.request.environ['REQUEST_URI'] = flask.request.url
-
- request_path = request_url.path
- if request_path in handlers:
- return handlers[request_path]
- request_dir = re.sub(r'[^/]+$', '', request_path)
- if request_dir in handlers:
- return handlers[request_dir]
- return flask.abort(404)
+ def run_simple(host, port, app, **kwargs):
+ server = make_server(host, port, wrapper)
+ print " * Running on http://%s:%i/" % server.server_address
+ server.serve_forever()
if __name__ == "__main__":
- app.run(debug=True)
+ run_simple("localhost", 5000, multiplex, use_reloader=True, use_debugger=True)
« no previous file with comments | « multiplexer.fcgi ('k') | sitescripts/web.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld