aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod/app.py')
-rw-r--r--libpathod/app.py23
1 files changed, 4 insertions, 19 deletions
diff --git a/libpathod/app.py b/libpathod/app.py
index fb1d6a2d..1910e80e 100644
--- a/libpathod/app.py
+++ b/libpathod/app.py
@@ -4,6 +4,8 @@ import version, language, utils
from netlib import http_uastrings
logging.basicConfig(level="DEBUG")
+
+
def make_app(noapi):
app = Flask(__name__)
@@ -14,20 +16,17 @@ def make_app(noapi):
version = version.IVERSION
)
-
@app.route('/api/log')
def api_log():
return jsonify(
log = app.config["pathod"].get_log()
)
-
@app.route('/api/clear_log')
def api_clear_log():
app.config["pathod"].clear_log()
return "OK"
-
def render(s, cacheable, **kwargs):
kwargs["noapi"] = app.config["pathod"].noapi
kwargs["nocraft"] = app.config["pathod"].nocraft
@@ -37,30 +36,25 @@ def make_app(noapi):
resp.headers["Cache-control"] = "public, max-age=4320"
return resp
-
@app.route('/')
@app.route('/index.html')
def index():
return render("index.html", True, section="main")
-
@app.route('/download')
@app.route('/download.html')
def download():
return render("download.html", True, section="download", version=version.VERSION)
-
@app.route('/about')
@app.route('/about.html')
def about():
return render("about.html", True, section="about")
-
@app.route('/docs/pathod')
def docs_pathod():
return render("docs_pathod.html", True, section="docs", subsection="pathod")
-
@app.route('/docs/language')
def docs_language():
return render(
@@ -69,29 +63,24 @@ def make_app(noapi):
subsection="lang"
)
-
@app.route('/docs/pathoc')
def docs_pathoc():
return render("docs_pathoc.html", True, section="docs", subsection="pathoc")
-
@app.route('/docs/libpathod')
def docs_libpathod():
return render("docs_libpathod.html", True, section="docs", subsection="libpathod")
-
@app.route('/docs/test')
def docs_test():
return render("docs_test.html", True, section="docs", subsection="test")
-
@app.route('/log')
def log():
if app.config["pathod"].noapi:
abort(404)
return render("log.html", False, section="log", log=app.config["pathod"].get_log())
-
@app.route('/log/<int:lid>')
def onelog(lid):
item = app.config["pathod"].log_by_id(int(lid))
@@ -100,7 +89,6 @@ def make_app(noapi):
l = pprint.pformat(item)
return render("onelog.html", False, section="log", alog=l, lid=lid)
-
def _preview(is_request):
if is_request:
template = "request_preview.html"
@@ -121,9 +109,9 @@ def make_app(noapi):
try:
if is_request:
- r = language.parse_request(app.config["pathod"].request_settings, spec)
+ r = language.parse_requests(spec)[0]
else:
- r = language.parse_response(app.config["pathod"].request_settings, spec)
+ r = language.parse_response(spec)
except language.ParseException, v:
args["syntaxerror"] = str(v)
args["marked"] = v.marked()
@@ -144,14 +132,11 @@ def make_app(noapi):
args["output"] = utils.escape_unprintables(s.getvalue())
return render(template, False, **args)
-
@app.route('/response_preview')
def response_preview():
return _preview(False)
-
@app.route('/request_preview')
def request_preview():
return _preview(True)
return app
-