Fix: KeyError

This commit is contained in:
Julien Palard 2023-04-25 21:48:05 +02:00
parent a03a5558d6
commit d70b7db79a
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
1 changed files with 2 additions and 2 deletions

View File

@ -53,7 +53,7 @@ class PasteView(View):
paste = get_object_or_404(Paste, slug=path)
paste.incr_viewcount()
if "html" in request.headers["accept"]:
if "html" in request.headers.get("accept", "html"):
return HttpResponse(paste_to_html(paste.filename, paste.content))
else:
return HttpResponse(paste.content, content_type="text/plain")
@ -124,7 +124,7 @@ class ListView(View):
"viewcount",
),
)
if "html" in request.headers["accept"]:
if "html" in request.headers.get("accept", "html"):
return HttpResponse(
loader.render_to_string(
"paste/show-markdown.html", {"highlighted": markdown_to_html(table)}