
    g                         d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 ddl
mZmZmZmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ d
 ZddZ ed      Zd ZddZy)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)FileResponseHttp404HttpResponseHttpResponseNotModified)ContextEngineTemplateDoesNotExistloader)	safe_join)	http_dateparse_http_date)gettext)gettext_lazyc                 @    t        t              j                  dz  | z  S )z
    Return a path to a builtin template.

    Avoid calling this function at the module level or in a class-definition
    because __file__ may not exist, e.g. in frozen environments.
    	templates)r   __file__parent)names    k/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/views/static.pybuiltin_template_pathr      s     >  ;.55    c                    t        j                  |      j                  d      }t        t	        ||            }|j                         r"|rt        ||      S t        t        d            |j                         st        t        d      d|iz        |j                         }t        | j                  j                  d      |j                        s
t               S t!        j"                  t%        |            \  }}|xs d}t'        |j)                  d      |      }t+        |j                        |j,                  d	<   |r||j,                  d
<   |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('<path: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 existpathHTTP_IF_MODIFIED_SINCEzapplication/octet-streamrb)content_typezLast-ModifiedzContent-Encoding)	posixpathnormpathlstripr   r   is_dirdirectory_indexr   _existsstatwas_modified_sinceMETAgetst_mtimer   	mimetypes
guess_typestrr   openr   headers)	requestr   document_rootshow_indexesfullpathstatobjr   encodingresponses	            r   server7      s&     d#**3/DImT23H"422aABCC??a78FH;MMNNmmoG12G4D4D '((&11#h-@L(=#=LHMM$/lKH(1'2B2B(CH_%/7+,Or   zIndex of %(directory)sc                 j   	 t        j                  ddg      }i }g }|j                         D ]^  }|j                  j                  d	      rt        |j                  |            }|j                         r|d
z  }|j                  |       ` |j!                  | d
z   |d       t#        j%                  |            S # t        $ rj t        d      j	                  d      5 }t        ddi      j                  |j                               }d d d        n# 1 sw Y   nxY wt               }Y w xY w)Nzstatic/directory_index.htmlzstatic/directory_indexzdirectory_index.htmlzutf-8)r5   i18nzdjango.templatetags.i18n)	libraries.r   )	directory	file_list)r   select_templater
   r   r.   r	   from_stringreadr   iterdirr   
startswithr-   relative_tor"   appendupdater   render)r   r3   tcfhfilesfurls           r   r#   r#   G   s   ""-(
 Evv  %ammH-.Cxxzs
LL   HH	
 $$+   "#9:???QUW&*D!EFRR	A RQQ Is)   B? ?$D2#,D	D2D!	D21D2c                     	 | t         t        |       }t        |      |kD  rt         	 y# t         t        f$ r Y yw xY w)a  
    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.
    TF)
ValueErrorr   intOverflowError)headermtimeheader_mtimes      r   r'   r'   g   sQ    >&v.u:$ %  & s   '+ ==)NF)Nr   )__doc__r+   r   pathlibr   django.httpr   r   r   r   django.templater   r	   r
   r   django.utils._osr   django.utils.httpr   r   django.utils.translationr   r$   r   r   r7   template_translatabler#   r'    r   r   <module>r]      sQ   
    T T I I & 8 1 16$P %%=> %@r   