caf8a43f4f8c92e6a73a13e507893bf3fca9a7c5
[prawokultury.git] / fnpdjango / utils / views.py
1 """
2 View-specific utilities.
3 """
4
5 from django.conf import settings
6 from django.http import HttpResponse, HttpResponseRedirect
7
8
9 def serve_file(url):
10     """Serves an URL either though Nginx's X-accel, or by redirection.""" 
11     if settings.X_ACCEL_REDIRECT:
12         response = HttpResponse()
13         response['Content-Type'] = ""
14         response['X-Accel-Redirect'] = url
15         return response
16     else:
17         return HttpResponseRedirect(url)