| 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) |