ó
    ×›‘h(  ã                   óì   • S r SSKrSSKrSSKrSSKJrJr  SSKJrJ	r	  SSK
JrJrJrJr  SSKJr  SSKJrJrJrJrJrJrJrJr   " S S	\R4                  5      rS
 r " S S\R8                  5      rS rg)z9
Support for creating a service which runs a web server.
é    N)ÚserviceÚstrports)Ú
interfacesÚreactor)Ú	deprecateÚreflectÚ
threadpoolÚusage)Úpb)ÚdemoÚdistribÚresourceÚscriptÚserverÚstaticÚtwcgiÚwsgic                   óž  • \ rS rSrSrSr/ SQ/ SQ/ SQ/r/ SQ/ SQ/r\R                  S	S
S\	R                  R                  < S3S-   /5        \R                  " \R                  " S5      \R                  " S5      \R                  " S5      S.S9rSrS rS r\rS rS rS r\rS r\rS rS rS rS rS rS r\r S r!S  r"S! r#S" r$S#r%g$)%ÚOptionsé   z:
Define the options accepted by the I{twistd web} plugin.
z[web options])ÚlogfileÚlNz/Path to web CLF (Combined Log Format) log file.)ÚcertificateÚcú
server.pemz=(DEPRECATED: use --listen) SSL certificate to use for HTTPS. )ÚprivkeyÚkr   z<(DEPRECATED: use --listen) SSL certificate to use for HTTPS.)ÚnotracebacksÚnzY(DEPRECATED: Tracebacks are disabled by default. See --enable-tracebacks to turn them on.)údisplay-tracebacksÚ z�Show uncaught exceptions during rendering tracebacks to the client. WARNING: This may be a security risk and expose private data!Úpersonalr!   zsInstead of generating a webserver, generate a ResourcePublisher which listens on  the port given by --listen, or ~/Ú zif --listen is not specified.z*.logz*.pem)r   r   r   )Ú
optActionsz‡This starts a webserver.  If you specify no arguments, it will be a
demo webserver that has the Test class from twisted.web.demo in it.c                 ó~   • [         R                  R                  U 5        / U S'   S U S'   / U S'   / U S'   S =U S'   U S'   g )NÚindexesÚrootÚextraHeadersÚportsÚportÚhttps)r
   r   Ú__init__©Úselfs    ÚSC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/tap.pyr,   ÚOptions.__init__X   sK   € Ü�‰×Ñ˜tÔ$ØˆˆY‰ØˆˆV‰Ø!ˆˆ^ÑØˆˆW‰Ø'+Ð+ˆˆV‰�t˜G’}ó    c           	      ó°   • [         R                  " U R                  [        R                  " SSSS5      5      n[
        R                  " U[        SS9  XS'   g)	zP
(DEPRECATED: use --listen)
Strports description of port to start the server on
ÚTwistedé   é   r   é   ©ÚcategoryÚ
stacklevelr*   N)r   ÚgetDeprecationWarningStringÚopt_portÚincrementalÚVersionÚwarningsÚwarnÚDeprecationWarning©r.   r*   Úmsgs      r/   r;   ÚOptions.opt_port`   sH   € ô
 ×3Ò3Ø�M‰Mœ;×.Ò.¨y¸"¸aÀÓCó
ˆô 	�Š�cÔ$6À1ÒEØˆVŠr1   c           	      ó°   • [         R                  " U R                  [        R                  " SSSS5      5      n[
        R                  " U[        SS9  XS'   g)	z?
(DEPRECATED: use --listen)
Port to listen on for Secure HTTP.
r3   r4   r5   r   r6   r7   r+   N)r   r:   Ú	opt_httpsr<   r=   r>   r?   r@   rA   s      r/   rE   ÚOptions.opt_httpsm   sH   € ô
 ×3Ò3Ø�N‰NœK×/Ò/°	¸2¸qÀ!ÓDó
ˆô 	�Š�cÔ$6À1ÒEØˆWŠr1   c                 ó,   • U S   R                  U5        g)zQ
Add an strports description of port to start the server on.
[default: tcp:8080]
r)   N©Úappend)r.   r*   s     r/   Ú
opt_listenÚOptions.opt_listenx   s   € ð
 	ˆW‰×Ñ˜TÕ"r1   c                 ó,   • U S   R                  U5        g)zZ
Add the name of a file used to check for directory indexes.
[default: index, index.html]
r&   NrH   )r.   Ú	indexNames     r/   Ú	opt_indexÚOptions.opt_index   s   € ð
 	ˆY‰×Ñ˜yÕ)r1   c                 ó4   • [         R                  " 5       U S'   g)zK
Makes a server with ~/public_html and ~/.twistd-web-pb support for
users.
r'   N)r   ÚUserDirectoryr-   s    r/   Úopt_userÚOptions.opt_userˆ   s   € ô
 ×,Ò,Ó.ˆˆVŠr1   c                 ó  • [         R                  " [        R                  R	                  U5      5      U S'   [
        R                  [
        R                  S.U S   l        [        R                  U S   R                  S'   g)zÖ
<path> is either a specific file or a directory to be set as the root
of the web server. Use this if you have a directory full of HTML, cgi,
epy, or rpy files or any other files that you want to be served up raw.
r'   )z.epyz.rpyz.cgiN)r   ÚFileÚosÚpathÚabspathr   ÚPythonScriptÚResourceScriptÚ
processorsr   Ú	CGIScript)r.   rW   s     r/   Úopt_pathÚOptions.opt_path‘   s]   € ô —{’{¤2§7¡7§?¡?°4Ó#8Ó9ˆˆV‰ä×'Ñ'Ü×)Ñ)ñ#
ˆˆV‰Ôô +0¯/©/ˆˆV‰×Ñ Ò'r1   c                 óè   • [        U S   [        R                  5      (       d  [        R                  " S5      eUR                  SS5      u  p#[        R                  " U5      U S   R                  U'   g)zP
`ext=class' where `class' is added as a Processor for files ending
with `ext'.
r'   z*You can only use --processor after --path.Ú=é   N)	Ú
isinstancer   rU   r
   Ú
UsageErrorÚsplitr   Ú
namedClassr[   )r.   ÚprocÚextÚklasss       r/   Úopt_processorÚOptions.opt_processorž   s\   € ô
 ˜$˜v™,¬¯©×4Ñ4Ü×"Ò"Ð#OÓPÐPØ—Z‘Z  QÓ'‰
ˆÜ'.×'9Ò'9¸%Ó'@ˆˆV‰×Ñ Ò$r1   c                 óD   • [         R                  " U5      nU" 5       U S'   g)z>
Create a Resource subclass with a zero-argument constructor.
r'   N)r   re   )r.   Ú	classNameÚclassObjs      r/   Ú	opt_classÚOptions.opt_class¨   s   € ô ×%Ò% iÓ0ˆÙ“zˆˆVŠr1   c                 ó6   • [         R                  " U5      U S'   g)z@
An .rpy file to be used as the root resource of the webserver.
r'   N)r   ÚResourceScriptWrapper)r.   Únames     r/   Úopt_resource_scriptÚOptions.opt_resource_script¯   s   € ô ×3Ò3°DÓ9ˆˆVŠr1   c                 óx  •  [         R                  " U5      n[        R                  " 5       n[        R                  " UR                  5        [        R                  " SSUR                  5        [        R                  " [        X25      U S'   g! [        [        4 a    [        R
                  " SU< 35      ef = f)zW
The FQPN of a WSGI application object to serve as the root resource of
the webserver.
zNo such WSGI application: ÚafterÚshutdownr'   N)r   ÚnamedAnyÚAttributeErrorÚ
ValueErrorr
   rc   r	   Ú
ThreadPoolr   ÚcallWhenRunningÚstartÚaddSystemEventTriggerÚstopr   ÚWSGIResource)r.   rr   ÚapplicationÚpools       r/   Úopt_wsgiÚOptions.opt_wsgiµ   s—   € ð
	JÜ!×*Ò*¨4Ó0ˆKô ×$Ò$Ó&ˆÜ×Ò §
¡
Ô+Ü×%Ò% g¨z¸4¿9¹9ÔEÜ×(Ò(¬°$ÓDˆˆVŠøô ¤
Ð+ó 	JÜ×"Ò"Ð%?À¹xÐ#HÓIÐIð	Jús   ‚B Â+B9c                 ó†   • [        U S   [        R                  5      (       d  [        R                  " S5      eXS   l        g)z1
Specify the default mime-type for static files.
r'   z*You can only use --mime_type after --path.N)rb   r   rU   r
   rc   ÚdefaultType)r.   r†   s     r/   Úopt_mime_typeÚOptions.opt_mime_typeÃ   s5   € ô ˜$˜v™,¬¯©×4Ñ4Ü×"Ò"Ð#OÓPÐPØ#.ˆV‰Õ r1   c                 óœ   • [        U S   [        R                  5      (       d  [        R                  " S5      eU S   R                  S5        g)zD
Specify whether or not a request for 'foo' should return 'foo.ext'
r'   z1You can only use --allow_ignore_ext after --path.Ú*N©rb   r   rU   r
   rc   Ú	ignoreExtr-   s    r/   Úopt_allow_ignore_extÚOptions.opt_allow_ignore_extÍ   sC   € ô ˜$˜v™,¬¯©×4Ñ4Ü×"Ò"ØFóð ð 	ˆV‰×Ñ˜sÕ#r1   c                 óœ   • [        U S   [        R                  5      (       d  [        R                  " S5      eU S   R                  U5        g)zD
Specify an extension to ignore.  These will be processed in order.
r'   z+You can only use --ignore_ext after --path.Nr‹   )r.   rg   s     r/   Úopt_ignore_extÚOptions.opt_ignore_ext×   s=   € ô ˜$˜v™,¬¯©×4Ñ4Ü×"Ò"Ð#SÓTÐTØˆV‰×Ñ˜sÕ#r1   c                 ó�   • UR                  SS5      u  p#U S   R                  UR                  5       UR                  5       45        g)zg
Specify an additional header to be included in all responses. Specified
as "HeaderName: HeaderValue".
Ú:ra   r(   N)rd   rI   Ústrip)r.   Úheaderrr   Úvalues       r/   Úopt_add_headerÚOptions.opt_add_headerß   s:   € ð
 —l‘l 3¨Ó*‰ˆØˆ^Ñ×#Ñ# T§Z¡Z£\°5·;±;³=Ð$AÕBr1   c                 ó\  • U S   b  U S   R                  U S   5        U S   bG   [        R                  " S5        SR                  U S   U S   U S	   5      nU S   R                  U5        [        U S   5      S
:X  aŒ  U S   (       am  [        R                  R                  [        R                  R                  S[        R                  R                  5      5      nU S   R                  SU-   5        gU S   R                  S5        gg! [         a    [        R
                  " S5      ef = f)a  
Set up conditional defaults and check for dependencies.

If SSL is not available but an HTTPS server was configured, raise a
L{UsageError} indicating that this is not possible.

If no server port was supplied, select a default appropriate for the
other options supplied.
r*   Nr)   r+   zOpenSSL.SSLzSSL support not installedz$ssl:port={}:privateKey={}:certKey={}r   r   r   r"   Ú~zunix:ztcp:8080)rI   r   ÚnamedModuleÚImportErrorr
   rc   ÚformatÚlenrV   rW   Ú
expanduserÚjoinr   rQ   ÚuserSocketName)r.   Ú
sslStrportrW   s      r/   ÚpostOptionsÚOptions.postOptionsç   s  € ð �‰<Ñ#Ø�‰M× Ñ   f¡Ô.Ø�‰=Ñ$ðDÜ×#Ò# MÔ2ð @×FÑFØ�W‘Ø�Y‘Ø�]Ñ#óˆJð
 �‰M× Ñ  Ô,Üˆt�G‰}Ó Ó"Ø�J×Ü—w‘w×)Ñ)Ü—G‘G—L‘L ¤g×&;Ñ&;×&JÑ&JÓKó�ð �W‘×$Ñ$ W¨t¡^Õ4à�W‘×$Ñ$ ZÕ0ð #øô ó DÜ×&Ò&Ð'BÓCÐCðDús   ¥D
 Ä
!D+© N)&Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚsynopsisÚoptParametersÚoptFlagsrI   r   rQ   r¡   r
   ÚCompletionsÚCompleteFilesÚcompDataÚlongdescr,   r;   Úopt_prE   rJ   rN   Úopt_irR   Úopt_ur]   ri   rn   rs   rƒ   r‡   Úopt_mr�   r�   r—   r£   Ú__static_attributes__r¥   r1   r/   r   r      s(  † ñð €Hò 	Rò	
ò	
ð€Mò"	
ò	
ð€Hð( ‡O�OàÙð %,×$9Ñ$9×$HÔ$HðKð .ñ.ð	
ô	ð × Ò à×*Ò*¨7Ó3Ø ×.Ò.¨wÓ7Ø×*Ò*¨7Ó3ñ
ñ€HðG€Hò,ò	ð €Eò	ò#ò*ð €Eò/ð €Eò:òAò"ò:òEò/ð €Eò$ò$òCõ1r1   r   c                 óV   • [         R                  " [        R                  " U 5      5      $ )z´
Create and return a factory which will respond to I{distrib} requests
against the given site.

@type site: L{twisted.web.server.Site}
@rtype: L{twisted.internet.protocol.Factory}
)r   ÚPBServerFactoryr   ÚResourcePublisher)Úsites    r/   ÚmakePersonalServerFactoryr»     s    € ô ×Òœg×7Ò7¸Ó=Ó>Ð>r1   c                   ó    • \ rS rSrS rS rSrg)Ú_AddHeadersResourcei  c                 ó   • Xl         X l        g ©N)Ú_originalResourceÚ_headers)r.   ÚoriginalResourceÚheaderss      r/   r,   Ú_AddHeadersResource.__init__  s   € Ø!1ÔØ�r1   c                 ó˜   • U R                    H   u  p4UR                  R                  X45        M"     U R                  R	                  X5      $ r¿   )rÁ   ÚresponseHeadersÚaddRawHeaderrÀ   ÚgetChildWithDefault)r.   rr   Úrequestr   Úvs        r/   rÈ   Ú'_AddHeadersResource.getChildWithDefault  s=   € Ø—M”M‰DˆAØ×#Ñ#×0Ñ0°Ö6ñ "à×%Ñ%×9Ñ9¸$ÓHÐHr1   )rÁ   rÀ   N)r¦   r§   r¨   r©   r,   rÈ   r¶   r¥   r1   r/   r½   r½     s   † ò õIr1   r½   c           	      ó0  • [         R                  " 5       nU S   (       a  U S   nU S   (       a  U S   U S   l        O[        R                  " 5       n[        U[        R                  5      (       a*  UR                  R                  [        R                  U5        U S   (       a  [        X S   5      nU S   (       a  [        R                  " X S   S9nO[        R                  " U5      nU S   (       a  SUl        U S   (       aH  [         R"                  " S	[$        R&                  " S
SSS5      5      n[(        R*                  " U[,        SS9  U S   (       a  [/        U5      nU S    H*  n[0        R                   " XS5      nUR3                  U5        M,     U$ )Nr'   r&   r(   r   )ÚlogPathr    Tr   z--notracebacksr3   é   é   r   r6   r7   r"   r)   )r   ÚMultiServiceÚ
indexNamesr   ÚTestrb   r   rU   ÚregistryÚsetComponentr   ÚIServiceCollectionr½   r   ÚSiteÚdisplayTracebacksr   Ú_getDeprecationWarningStringr<   r=   r>   r?   r@   r»   r   ÚsetServiceParent)ÚconfigÚsr'   rº   rB   r*   Úsvcs          r/   ÚmakeServicerÝ     sK  € Ü×ÒÓ€AØˆf‡~Ø�f‰~ˆØ�)×Ø(.¨yÑ(9ˆF�6‰NÔ%øô �yŠy‹{ˆä�$œŸ™×$Ñ$Ø�‰×"Ñ"¤:×#@Ñ#@À!ÔDàˆn×Ü" 4°Ñ)?Ó@ˆàˆi×Ü�{Š{˜4°	Ñ):Ñ;‰ä�{Š{˜4Ó ˆàÐ"×#Ø!%ˆÔð ˆn×Ü×4Ò4Øœk×1Ò1°)¸RÀÀAÓFó
ˆô 	�Š�cÔ$6À1ÒEàˆj×Ü(¨Ó.ˆØ�w”ˆÜ×Ò˜tÓ*ˆØ×Ñ˜QÖñ  ð €Hr1   )rª   rV   r>   r<   Útwisted.applicationr   r   Útwisted.internetr   r   Útwisted.pythonr   r   r	   r
   Útwisted.spreadr   Útwisted.webr   r   r   r   r   r   r   r   r   r»   ÚResourcer½   rÝ   r¥   r1   r/   Ú<module>rä      s^   ðñ
ó
 
Û ã ç 1ß 0ß @Ó @Ý ß T× TÓ Tôo1ˆe�m‰mô o1òd?ôI˜(×+Ñ+ô Ió$r1   