|
12 | 12 | import logging
|
13 | 13 |
|
14 | 14 | from django.conf import settings
|
15 |
| -from django.http import HttpResponseRedirect, Http404, JsonResponse, HttpResponse |
| 15 | +from django.http import HttpResponseRedirect, Http404, JsonResponse |
16 | 16 | from django.shortcuts import render, get_object_or_404, redirect
|
17 | 17 | from django.views.generic import TemplateView
|
18 | 18 |
|
|
21 | 21 | from readthedocs.core.resolver import resolve_path
|
22 | 22 | from readthedocs.core.symlink import PrivateSymlink, PublicSymlink
|
23 | 23 | from readthedocs.core.utils import broadcast
|
| 24 | +from readthedocs.core.views.serve import _serve_file |
24 | 25 | from readthedocs.projects.constants import PRIVATE
|
25 | 26 | from readthedocs.projects.models import Project, ImportedFile
|
26 | 27 | from readthedocs.projects.tasks import remove_dirs
|
@@ -153,8 +154,8 @@ def server_error_404(request, exception=None, template_name='404.html'): # pyli
|
153 | 154 | fullpath = os.path.join(basepath, filename)
|
154 | 155 |
|
155 | 156 | if os.path.exists(fullpath):
|
156 |
| - log.debug('Serving custom 404.html page for project: %', project.slug) |
157 |
| - r = HttpResponse(open(fullpath).read(), content_type='text/html') |
| 157 | + log.info('Serving custom 404.html page for project: %', project.slug) |
| 158 | + r = _serve_file(request, filename, basepath) |
158 | 159 | else:
|
159 | 160 | # Return the default 404 page generated by Read the Docs
|
160 | 161 | r = render(request, template_name)
|
|
0 commit comments