/servicios_web/gae/django-guestbook/src/django/views/static.py

https://github.com/enlaces/curso_python_dga_11 · Python · 41 lines · 27 code · 5 blank · 9 comment · 1 complexity · 4b9423561b39b7278b8984fd4611d973 MD5 · raw file

  1. """
  2. Views and functions for serving static files. These are only to be used
  3. during development, and SHOULD NOT be used in a production setting.
  4. """
  5. import mimetypes
  6. import os
  7. import posixpath
  8. import re
  9. import stat
  10. import urllib
  11. import warnings
  12. from email.Utils import parsedate_tz, mktime_tz
  13. from django.template import loader
  14. from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseNotModified
  15. from django.template import Template, Context, TemplateDoesNotExist
  16. from django.utils.http import http_date
  17. from django.contrib.staticfiles.views import \
  18. directory_index, was_modified_since, serve as staticfiles_serve
  19. def serve(request, path, document_root=None, show_indexes=False, insecure=False):
  20. """
  21. Serve static files below a given point in the directory structure.
  22. To use, put a URL pattern such as::
  23. (r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root' : '/path/to/my/files/'})
  24. in your URLconf. You must provide the ``document_root`` param. You may
  25. also set ``show_indexes`` to ``True`` if you'd like to serve a basic index
  26. of the directory. This index view will use the template hardcoded below,
  27. but if you'd like to override it, you can create a template called
  28. ``static/directory_index.html``.
  29. """
  30. warnings.warn("The view at `django.views.static.serve` is deprecated; "
  31. "use the path `django.contrib.staticfiles.views.serve` "
  32. "instead.", PendingDeprecationWarning)
  33. return staticfiles_serve(request, path, document_root, show_indexes, insecure)