
    h                         S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S S	KJrJr  S S
KJr   " S S5      r " S S\\5      r " S S\\5      rg)    )urlparse)url2pathname)sync_to_async)settings)utils)serve)ASGIHandler)response_for_exception)WSGIHandlerget_path_info)Http404c                   F    \ rS rSrSrSrS rS rS rS r	S r
S	 rS
 rSrg)StaticFilesHandlerMixin   z0
Common methods used by WSGI and ASGI handlers.
Tc                     g N selfs    U/var/www/html/env/lib/python3.13/site-packages/django/contrib/staticfiles/handlers.pyload_middleware'StaticFilesHandlerMixin.load_middleware   s     	    c                 L    [         R                  " 5         [        R                  $ r   )r   check_settingsr   
STATIC_URLr   s    r   get_base_url$StaticFilesHandlerMixin.get_base_url   s    """r   c                 t    UR                  U R                  S   5      =(       a    U R                  S   (       + $ )z
Check if the path should be handled. Ignore the path if:
* the host is provided as part of the base_url
* the request's path isn't under the media path (or equal)
      )
startswithbase_url)r   paths     r   _should_handle&StaticFilesHandlerMixin._should_handle!   s-     t}}Q/0Iq9I5IIr   c                 T    UR                  U R                  S   5      n[        U5      $ )zG
Return the relative path to the media file on disk for the given URL.
r    )removeprefixr#   r   )r   urlrelative_urls      r   	file_path!StaticFilesHandlerMixin.file_path)   s(     ''a(89L))r   c                 H    [        XR                  UR                  5      SS9$ )zServe the request path.T)insecure)r   r+   r$   )r   requests     r   r   StaticFilesHandlerMixin.serve0   s    WnnW\\:TJJr   c                 j     U R                  U5      $ ! [         a  n[        X5      s S nA$ S nAff = fr   )r   r   r
   r   r/   es      r   get_response$StaticFilesHandlerMixin.get_response4   s1    	6::g&& 	6)'55	6s    
2
-22c                    #     [        U R                  SS9" U5      I S h  vN $  N! [         a'  n[        [        SS9" X5      I S h  vN  s S nA$ S nAff = f7f)NF)thread_sensitive)r   r   r   r
   r2   s      r   get_response_async*StaticFilesHandlerMixin.get_response_async:   sX     	&tzzEJ7SSSS 	&'=PUV   	sH   A( &( A( 
AA	A
AAAAAr   N)__name__
__module____qualname____firstlineno____doc__handles_filesr   r   r%   r+   r   r4   r8   __static_attributes__r   r   r   r   r      s3     M
#J*K6r   r   c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )StaticFilesHandlerC   z
WSGI middleware that intercepts calls to the static files directory, as
defined by the STATIC_URL setting, and serves those files.
c                 j   > Xl         [        U R                  5       5      U l        [        TU ]  5         g r   )applicationr   r   r#   super__init__)r   rE   	__class__s     r   rG   StaticFilesHandler.__init__I   s)    & !2!2!45r   c                    > U R                  [        U5      5      (       d  U R                  X5      $ [        TU ]  X5      $ r   )r%   r   rE   rF   __call__)r   environstart_responserH   s      r   rK   StaticFilesHandler.__call__N   s:    ""=#9::##G<<w88r   rE   r#   )	r:   r;   r<   r=   r>   rG   rK   r@   __classcell__rH   s   @r   rB   rB   C   s    

9 9r   rB   c                   >   ^  \ rS rSrSrS rU 4S jrU 4S jrSrU =r	$ )ASGIStaticFilesHandlerT   z
ASGI application which wraps another and intercepts requests for static
files, passing them off to Django's static file serving.
c                 L    Xl         [        U R                  5       5      U l        g r   )rE   r   r   r#   )r   rE   s     r   rG   ASGIStaticFilesHandler.__init__Z   s    & !2!2!45r   c                    >#    US   S:X  a1  U R                  US   5      (       a  [        TU ]	  XU5      I S h  vN $ U R                  XU5      I S h  vN $  N N7f)Ntypehttpr$   )r%   rF   rK   rE   )r   scopereceivesendrH   s       r   rK   ASGIStaticFilesHandler.__call__^   s\     =F"t':':5='I'I )%$???%%ed;;; @;s!   6AAAAAAc                   >^#    [         TU ]  U5      I S h  vN nUR                  R                  UR                  5        UR
                  (       a/  UR                  (       d  UR                  mU4S jnU" 5       Ul        U$  Nk7f)Nc                 d   >#    [        [        5      " T5      I S h  vN  H  n U 7v   M
     g  N7fr   )r   list)part	_iterators    r   awrapper;ASGIStaticFilesHandler.get_response_async.<locals>.awrappern   s&     "/"5i"@@@DJ As   0.0)rF   r8   _resource_closersappendclose	streamingis_asyncstreaming_content)r   r/   responserc   rb   rH   s       @r   r8   )ASGIStaticFilesHandler.get_response_asyncg   sg     3G<<""))'--8h&7&7 22I *2H& =s   BBA,BrO   )
r:   r;   r<   r=   r>   rG   rK   r8   r@   rP   rQ   s   @r   rS   rS   T   s    
6< r   rS   N)urllib.parser   urllib.requestr   asgiref.syncr   django.confr   django.contrib.staticfilesr    django.contrib.staticfiles.viewsr   django.core.handlers.asgir	   django.core.handlers.exceptionr
   django.core.handlers.wsgir   r   django.httpr   r   rB   rS   r   r   r   <module>rw      sL    ! ' &   , 2 1 A @ 1 1h90+ 9"4k r   