
    Mhj                        U d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ erdd
lmZ dZ G d deej                  Zg Zded<   dS )z.Serve files directly from the ContentsManager.    )annotationsN)decodebytes)TYPE_CHECKING)ensure_async)web)
authorized)JupyterHandler)	Awaitablecontentsc                       e Zd ZdZeZe fd            Zej	        e
d
d                        Zej	        e
dd	                        Z xZS )FilesHandlerzserve files via ContentsManager

    Normally used when ContentsManager is not a FileContentsManager.

    FileContentsManager subclasses use AuthenticatedFilesHandler by default,
    a subclass of StaticFileHandler.
    c                0    t                      j        dz   S )zThe content security policy.z; sandbox allow-scripts)supercontent_security_policy)self	__class__s    ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyter_server/files/handlers.pyr   z$FilesHandler.content_security_policy"   s    
 ww.1JJJ    pathstrreturnAwaitable[None] | Nonec                    |                      |d           |                                  |                      |d          S )zThe head response.F)include_body)getcheck_xsrf_cookie)r   r   s     r   headzFilesHandler.head)   sB     	E***   xx5x111r   Tc                  K   |                                   | j        }|j        sVt          |                    |                     d{V r.| j                            d           t          j        d          |	                    d          }d|v r|
                    dd          \  }}n|}t          |                    |d|                     d{V }|                     dd          r|                     |           |                                                    d	          r|                     d
d           nt#          j        |          \  }}|dk    r|                     d
d           |dk    r|                     d
d           nk||                     d
d           nR||                     d
|           n9|d         dk    r|                     d
d           n|                     d
d           |r{|d         dk    r>|d                             d          }	|                     t+          |	                     n|                     |d                    |                                  dS dS )zGet a file by path.Nz,Refusing to serve hidden file, via 404 Errori  /   file)typecontentdownloadz.ipynbzContent-Typezapplication/x-ipynb+jsonz
text/plainztext/plain; charset=UTF-8gzipzapplication/gzipzapplication/octet-streamformatbase64r#   ascii)r   contents_managerallow_hiddenr   	is_hiddenloginfor   	HTTPErrorstriprsplitr   get_argumentset_attachment_headerlowerendswith
set_header	mimetypes
guess_typeencodewriter   flush)
r   r   r   cm_namemodelcur_mimeencoding	b64_bytess
             r   r   zFilesHandler.get1   s     
 	   " 	%bll46H6H)I)I#I#I#I#I#I#I 	%HMMHIII-$$$zz#$;;kk#q))GAttD"266$V\6#R#RSSSSSSSSZ.. 	-&&t,,, ::<<  ** 	MOON,FGGGG!*!5d!;!;Hh<''0KLLL6!!0BCCCC%0JKKKK%9999xH,,0JKKKK0KLLL 	X(**!),33G<<	

;y112222

5+,,,JJLLLLL	 	r   )r   r   r   r   )T)__name__
__module____qualname____doc__AUTH_RESOURCEauth_resourcepropertyr   r   authenticatedr   r   r   __classcell__)r   s   @r   r   r      s          "MK K K K XK 	2 2 2 Z 2 	. . . Z . . . . .r   r   zlist[JupyterHandler]default_handlers)rE   
__future__r   r6   r'   r   typingr   jupyter_core.utilsr   tornador   jupyter_server.auth.decoratorr   jupyter_server.base.handlersr	   collections.abcr
   rF   StaticFileHandlerr   rK   __annotations__ r   r   <module>rV      s   4 4 4 # " " " " "                       + + + + + +       4 4 4 4 4 4 7 7 7 7 7 7 *))))))J J J J J>3#8 J J JZ *,  + + + + + +r   