diff --git a/libpathod/app.py b/libpathod/app.py index 17be448dc..e93a898fa 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -82,12 +82,17 @@ def _preview(is_request): template = "response_preview.html" spec = request.args["spec"] + args = dict( spec = spec, section = "main", syntaxerror = None, error = None ) + if not spec.strip(): + args["error"] = "Can't parse an empty spec." + return render(template, **args) + try: if is_request: r = rparse.parse_request(app.config["pathod"].request_settings, spec) diff --git a/libpathod/templates/request_preview.html b/libpathod/templates/request_preview.html index fe8a03e9f..eaf78898c 100644 --- a/libpathod/templates/request_preview.html +++ b/libpathod/templates/request_preview.html @@ -7,7 +7,6 @@
{{ marked }}{% elif error %} -
{{ error }}
{% else %}{{ marked }}{% elif error %} -
{{ error }}
{% else %}