From f373ecbc84e55414d0597b7391b2a9e7577717cf Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Wed, 8 Mar 2023 21:25:54 -0600 Subject: [PATCH] Optimize pdf description --- judge/views/problem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/judge/views/problem.py b/judge/views/problem.py index dde3acf..89cf177 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -450,11 +450,11 @@ class ProblemPdfDescriptionView(ProblemMixin, SingleObjectMixin, View): if not problem.pdf_description: raise Http404() response = HttpResponse() - # if request.META.get("SERVER_SOFTWARE", "").startswith("nginx/"): - # response["X-Accel-Redirect"] = problem.pdf_description.path - # else: - with open(problem.pdf_description.path, "rb") as f: - response.content = f.read() + if request.META.get("SERVER_SOFTWARE", "").startswith("nginx/"): + response["X-Accel-Redirect"] = problem.pdf_description.path + else: + with open(problem.pdf_description.path, "rb") as f: + response.content = f.read() response["Content-Type"] = "application/pdf" response["Content-Disposition"] = "inline; filename=%s.pdf" % (problem.code,)