Skip to content

Commit 8f94b28

Browse files
committed
Add docstring to readthedocs.core.views.serve._serve_file
1 parent a33aee7 commit 8f94b28

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

readthedocs/core/views/serve.py

+17
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ def _serve_401(request, project):
139139

140140

141141
def _serve_file(request, filename, basepath):
142+
"""
143+
Serve media file via Django or NGINX based on ``PYTHON_MEDIA``.
144+
145+
When using ``PYTHON_MEDIA=True`` (or when ``DEBUG=True``) the file is served
146+
by ``django.views.static.serve`` function.
147+
148+
On the other hand, when ``PYTHON_MEDIA=False`` the file is served by using
149+
``X-Accel-Redirect`` header for NGINX to take care of it and serve the file.
150+
151+
:param request: Django HTTP request
152+
:param filename: path to the filename to be served relative to ``basepath``
153+
:param basepath: base path to prepend to the filename
154+
155+
:returns: Django HTTP response object
156+
157+
:raises: ``Http404`` on ``UnicodeEncodeError``
158+
"""
142159
# Serve the file from the proper location
143160
if settings.DEBUG or getattr(settings, 'PYTHON_MEDIA', False):
144161
# Serve from Python

0 commit comments

Comments
 (0)