diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 23:13:04 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 23:13:04 +1200 |
commit | ab59d6dccf0d1f3715021a6c7ec3afb11c0c02d3 (patch) | |
tree | 7f8375ee72355c0d3d1a6d91c325fb3b21ae795e /libpathod/app.py | |
parent | 6c565e778f986055f0edd2a170e005f4adb45a5d (diff) | |
download | mitmproxy-ab59d6dccf0d1f3715021a6c7ec3afb11c0c02d3.tar.gz mitmproxy-ab59d6dccf0d1f3715021a6c7ec3afb11c0c02d3.tar.bz2 mitmproxy-ab59d6dccf0d1f3715021a6c7ec3afb11c0c02d3.zip |
Add preview for pathoc requests to web app.
Diffstat (limited to 'libpathod/app.py')
-rw-r--r-- | libpathod/app.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/libpathod/app.py b/libpathod/app.py index 111fafe5..6478964c 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -73,8 +73,8 @@ def onelog(lid): return render("onelog.html", section="log", alog=l, lid=lid) -@app.route('/preview') -def preview(): +@app.route('/response_preview') +def response_preview(): spec = request.args["spec"] args = dict( spec = spec, @@ -87,10 +87,33 @@ def preview(): except rparse.ParseException, v: args["syntaxerror"] = str(v) args["marked"] = v.marked() - return render("preview.html", **args) + return render("preview_response.html", **args) s = cStringIO.StringIO() r.preview_safe() r.serve(s, check=app.config["pathod"].check_size) args["output"] = utils.escape_unprintables(s.getvalue()) - return render("preview.html", **args) + return render("preview_response.html", **args) + + +@app.route('/request_preview') +def request_preview(): + spec = request.args["spec"] + args = dict( + spec = spec, + section = "main", + syntaxerror = None, + error = None + ) + try: + r = rparse.parse_request(app.config["pathod"].request_settings, spec) + except rparse.ParseException, v: + args["syntaxerror"] = str(v) + args["marked"] = v.marked() + return render("preview_request.html", **args) + + s = cStringIO.StringIO() + r.preview_safe() + r.serve(s, check=app.config["pathod"].check_size, host="example.com") + args["output"] = utils.escape_unprintables(s.getvalue()) + return render("preview_request.html", **args) |