diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 22:27:04 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 22:27:04 +1200 |
commit | 11896d21182d3afe14d7fa7a5c6ecc64d7fb636c (patch) | |
tree | d4f20eddbcddb4e2e8addec0cf3c712955364a10 /libpathod | |
parent | eb1f2c3fc40ccfc0db60776412add6a35af93bf9 (diff) | |
download | mitmproxy-11896d21182d3afe14d7fa7a5c6ecc64d7fb636c.tar.gz mitmproxy-11896d21182d3afe14d7fa7a5c6ecc64d7fb636c.tar.bz2 mitmproxy-11896d21182d3afe14d7fa7a5c6ecc64d7fb636c.zip |
Turn off /log when noapi is set.
Diffstat (limited to 'libpathod')
-rw-r--r-- | libpathod/app.py | 25 | ||||
-rw-r--r-- | libpathod/templates/frame.html | 2 |
2 files changed, 18 insertions, 9 deletions
diff --git a/libpathod/app.py b/libpathod/app.py index 2c4cea23..5de69337 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -26,35 +26,42 @@ def api(): return "OK" +def render(s, **kwargs): + kwargs["noapi"] = app.config["pathod"].noapi + return render_template(s, **kwargs) + + @app.route('/') @app.route('/index.html') def index(): - return render_template("index.html", section="main") + return render("index.html", section="main") @app.route('/docs/pathod') def docs_pathod(): - return render_template("docs_pathod.html", section="docs") + return render("docs_pathod.html", section="docs") @app.route('/docs/language') def docs_language(): - return render_template("docs_lang.html", section="docs") + return render("docs_lang.html", section="docs") @app.route('/docs/pathoc') def docs_pathoc(): - return render_template("docs_pathoc.html", section="docs") + return render("docs_pathoc.html", section="docs") @app.route('/docs/test') def docs_test(): - return render_template("docs_test.html", section="docs") + return render("docs_test.html", section="docs") @app.route('/log') def log(): - return render_template("log.html", section="log", log=app.config["pathod"].get_log()) + if app.config["pathod"].noapi: + abort(404) + return render("log.html", section="log", log=app.config["pathod"].get_log()) @app.route('/log/<int:lid>') @@ -63,7 +70,7 @@ def onelog(lid): if not item: abort(404) l = pprint.pformat(item) - return render_template("onelog.html", section="log", alog=l, lid=lid) + return render("onelog.html", section="log", alog=l, lid=lid) @app.route('/preview') @@ -80,9 +87,9 @@ def preview(): except rparse.ParseException, v: args["syntaxerror"] = str(v) args["marked"] = v.marked() - return render_template("preview.html", **args) + return render("preview.html", **args) s = cStringIO.StringIO() r.serve(s, check=app.config["pathod"].check_size) args["output"] = utils.escape_unprintables(s.getvalue()) - return render_template("preview.html", **args) + return render("preview.html", **args) diff --git a/libpathod/templates/frame.html b/libpathod/templates/frame.html index f176b15d..416f3eca 100644 --- a/libpathod/templates/frame.html +++ b/libpathod/templates/frame.html @@ -38,7 +38,9 @@ <div class="nav-collapse"> <ul class="nav"> <li {% if section== "main" %} class="active" {% endif %}><a href="/">home</a></li> + {% if not noapi %} <li {% if section== "log" %} class="active" {% endif %}><a href="/log">log</a></li> + {% endif %} <li class="dropdown {% if section== "docs" %}active{% endif %}"> <a class="dropdown-toggle" data-toggle="dropdown"> docs |