o a@sdZddlZddlZddlZddlmZddlmZmZm Z m Z ddl m Z m Z mZmZddlmZddlmZmZddlmZmZdd d Zd Zed ZddZdddZdS)z Views and functions for serving static files. These are only to be used during development, and SHOULD NOT be used in a production setting. N)Path) FileResponseHttp404 HttpResponseHttpResponseNotModified)ContextEngineTemplateDoesNotExistloader) safe_join) http_dateparse_http_date)gettext gettext_lazyFc Cst|d}tt||}|r |rt||Sttd| s.ttdd|i| }t |j d|j|jsAtStt|\}}|pMd}t|d|d}t|j|jd <|rf||jd <|S) aF Serve static files below a given point in the directory structure. To use, put a URL pattern such as:: from django.views.static import serve path('', serve, {'document_root': '/path/to/my/files/'}) in your URLconf. You must provide the ``document_root`` param. You may also set ``show_indexes`` to ``True`` if you'd like to serve a basic index of the directory. This index view will use the template hardcoded below, but if you'd like to override it, you can create a template called ``static/directory_index.html``. /z'Directory indexes are not allowed here.u“%(path)s” does not existpathHTTP_IF_MODIFIED_SINCEzapplication/octet-streamrb) content_typez Last-ModifiedzContent-Encoding) posixpathnormpathlstriprr is_dirdirectory_indexr_existsstatwas_modified_sinceMETAgetst_mtimest_sizer mimetypes guess_typestrropenr headers) requestr document_root show_indexesfullpathstatobjrencodingresponser.5/usr/lib/python3/dist-packages/django/views/static.pyserves(    r0a {% load i18n %} {% blocktranslate %}Index of {{ directory }}{% endblocktranslate %}

{% blocktranslate %}Index of {{ directory }}{% endblocktranslate %}

zIndex of %(directory)scCsz tddg}Wntytddidt}t}Ynwi}g}|D]}|j dsDt | |}| r?|d7}| |q(||d|dt||S) Nzstatic/directory_index.htmlzstatic/directory_indexi18nzdjango.templatetags.i18n) libraries.r) directory file_list)r select_templater r from_string DEFAULT_DIRECTORY_INDEX_TEMPLATEriterdirname startswithr$ relative_torappendupdaterrender)rr*tcfilesfurlr.r.r/rSs.     rc Csvz-|durttd|tj}t|d}|d}|r#t||kr#tt||kr+tWdStttfy:YdSw)aI Was something modified since the user last downloaded it? header This is the value of the If-Modified-Since header. If this is None, I'll just return True. mtime This is the modification time of the item we're talking about. size This is the size of the item we're talking about. Nz^([^;]+)(; length=([0-9]+))?$TF) ValueErrorrematch IGNORECASEr intAttributeError OverflowError)headermtimesizematches header_mtime header_lenr.r.r/rls"  r)NF)Nrr)__doc__r"rrHpathlibr django.httprrrrdjango.templaterrr r django.utils._osr django.utils.httpr r django.utils.translationrrrr0r8template_translatablerrr.r.r.r/s   &