o
    ßý°j³›  ã                   @  s   U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	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 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 zddlZe ej!ej"fZ#de$d< W n e%yš   G dd„ dƒZ&e&ƒ Ze ej!fZ#Y nw dZ'ej(dkr´ze)dƒ W n e%y³   dZ'Y nw e*edƒZ+e+r¿ej,Z,nG dd„ dƒZ,zej-Z.W n e/yÖ   dZ.Y nw dZ0ej1ej2de3e4ej1e4 f ej5d f  Z6ej7�r
ddl8m9Z9 dd l8m:Z: dd!l;m<Z< dd"l=m>Z> G d#d$„ d$ej?ƒZ@G d%d&„ d&eƒZAdsd+d,„ZB	dtdud0d1„ZC	dvdwd5d6„ZDdxd7d8„ZE	dvdyd=d>„ZFdtdzdBdC„ZGd{dGdH„ZHd|dKdL„ZId}dMdN„ZJG dOdP„ dPeƒZKG dQdR„ dRejLeKƒZMG dSdT„ dTe,eKƒZN						d~dd_d`„ZOd€dadb„ZP							c						d�d‚dqdr„ZQdS )ƒaØ  A WSGI and HTTP server for use **during development only**. This
server is convenient to use, but is not designed to be particularly
stable, secure, or efficient. Use a dedicate WSGI server and HTTP
server when deploying to production.

It provides features like interactive debugging and code reloading. Use
``run_simple`` to start the server. Put this in a ``run.py`` script:

.. code-block:: python

    from myapp import create_app
    from werkzeug import run_simple
é    )ÚannotationsN)Údatetime)Ú	timedelta)Útimezone)ÚBaseHTTPRequestHandler)Ú
HTTPServer)Úunquote)Úurlsplité   ©Ú_log)Ú_wsgi_encoding_dance)ÚInternalServerError)Úparse_set_header)Ú
uri_to_iriztuple[type[Exception], ...]Úconnection_dropped_errorsc                   @  s   e Zd Zddd„ZdS )	Ú	_SslDummyÚnameÚstrÚreturnút.Anyc                 C  s   t dƒ‚)NzUSSL is unavailable because this Python runtime was not compiled with SSL/TLS support.)ÚRuntimeError©Úselfr   © r   úƒ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/werkzeug/serving.pyÚ__getattr__2   s   ÿz_SslDummy.__getattr__N©r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   1   s    r   TÚntÚcoloramaFÚforkc                   @  s   e Zd ZdS )ÚForkingMixInN)r   r   r    r   r   r   r   r$   I   s    r$   é€   ússl.SSLContextÚadhoc)ÚWSGIApplication)ÚWSGIEnvironment)ÚRSAPrivateKeyWithSerialization)ÚCertificatec                   @  s8   e Zd ZdZddd„Zdd	d
„Zddd„Zddd„ZdS )ÚDechunkedInputz8An input stream that handles Transfer-Encoding 'chunked'Úrfileút.IO[bytes]r   ÚNonec                 C  s   || _ d| _d| _d S )NFr   )Ú_rfileÚ_doneÚ_len)r   r-   r   r   r   Ú__init__d   s   
zDechunkedInput.__init__Úboolc                 C  ó   dS )NTr   ©r   r   r   r   Úreadablei   s   zDechunkedInput.readableÚintc              
   C  sZ   z| j  ¡  d¡}t| ¡ dƒ}W n ty" } ztdƒ|‚d }~ww |dk r+tdƒ‚|S )NÚlatin1é   zInvalid chunk headerr   z!Negative chunk length not allowed)r0   ÚreadlineÚdecoder8   ÚstripÚ
ValueErrorÚOSError)r   Úliner2   Úer   r   r   Úread_chunk_lenl   s   
€ÿzDechunkedInput.read_chunk_lenÚbufÚ	bytearrayc                 C  s  d}| j s‚|t|ƒk r‚| jdkr|  ¡ | _| jdkrd| _ | jdkrgtt|ƒ| jƒ}|| t|ƒkrP| j t|ƒ| ¡||d …< |  jt|ƒ| 8  _t|ƒ}n| j |¡|||| …< |  j|8  _||7 }| jdkry| j ¡ }|dvrytdƒ‚| j s‚|t|ƒk s|S )Nr   T)ó   
ó   
ó   z!Missing chunk terminating newline)	r1   Úlenr2   rB   Úminr0   Úreadr;   r?   )r   rC   rJ   ÚnÚ
terminatorr   r   r   Úreadintov   s*   






Þ$zDechunkedInput.readintoN)r-   r.   r   r/   ©r   r4   ©r   r8   )rC   rD   r   r8   )r   r   r    Ú__doc__r3   r7   rB   rM   r   r   r   r   r,   a   s    



r,   c                      sÚ   e Zd ZU dZded< ed7dd„ƒZd8d	d
„Zd9dd„Zd9‡ fdd„Z		d:d;dd„Z
d<‡ fdd„Zd7dd„Zd=dd„Ze d d!„ g ed"ƒ¢ed#d$ƒ¢D ƒ¡Zd%eed&ƒ< d>d?d+d,„Zd@d/d0„Zd@d1d2„ZdAd5d6„Z‡  ZS )BÚWSGIRequestHandlerz3A request handler that implements WSGI dispatching.ÚBaseWSGIServerÚserverr   r   c                 C  s   | j jS ©N)rS   Ú_server_versionr6   r   r   r   Úserver_version¤   s   z!WSGIRequestHandler.server_versionr)   c                 C  sH  t | jƒ}| jjd u rdnd}| jsd| _nt| jtƒr"| jdf| _|js2|jr2d|j› |j› �}n|j}t	|ƒ}i dd“d|“d	| j
“d
tj“d| jj“d| jj“dd“d| j“d| j“d| j“dd“dt|ƒ“dt|jƒ“dt| jƒ“dt| jƒ“d|  ¡ “d|  ¡ “| jjd t| jjd ƒ| jdœ¥}| j ¡ D ]1\}}d|v r¥qœ| ¡  dd¡}| dd¡}|dvrÉd |› �}||v rÉ|| › d!|› �}|||< qœd"t| d#¡ƒv rãd$|d%< t|d	 ƒ|d	< |jrî|jrî|j|d&< z| jjd$d'�}|d u�rt  !|¡|d(< W |S W |S  t"�y   | j #d)d*¡ Y |S  t$�y#   Y |S w )+NÚhttpÚhttps)ú<local>r   r   ú/zwsgi.version)r
   r   zwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocesszwsgi.run_onceFzwerkzeug.socketÚSERVER_SOFTWAREÚREQUEST_METHODÚSCRIPT_NAMEÚ Ú	PATH_INFOÚQUERY_STRINGÚREQUEST_URIÚRAW_URIÚREMOTE_ADDRÚREMOTE_PORTr
   )ÚSERVER_NAMEÚSERVER_PORTÚSERVER_PROTOCOLÚ_ú-z
)ÚCONTENT_TYPEÚCONTENT_LENGTHÚHTTP_ú,ÚchunkedÚHTTP_TRANSFER_ENCODINGTzwsgi.input_terminatedÚ	HTTP_HOST)Úbinary_formÚSSL_CLIENT_CERTÚerrorz&Cannot fetch SSL peer certificate info)%r	   ÚpathrS   Ússl_contextÚclient_addressÚ
isinstancer   ÚschemeÚnetlocr   r-   ÚsysÚstderrÚmultithreadÚmultiprocessÚ
connectionrV   Úcommandr   ÚqueryÚaddress_stringÚport_integerÚserver_addressÚrequest_versionÚheadersÚitemsÚupperÚreplacer   Úgetr,   ÚgetpeercertÚsslÚDER_cert_to_PEM_certr>   ÚlogÚAttributeError)r   Úrequest_urlÚ
url_schemeÚ	path_infoÚenvironÚkeyÚvalueÚ	peer_certr   r   r   Úmake_environ¨   sœ   
ÿþýüûúùø	÷
öõô
ó
ñ
ïîí
ê



ö
ùüüzWSGIRequestHandler.make_environr/   c                   sr  ˆj  dd¡ ¡  ¡ dkrˆj d¡ ˆ ¡  ˆ_‰d ‰d ‰d ‰d ‰d‰ d‡ ‡‡‡‡‡‡fd
d„‰d‡‡‡‡fdd„	‰d‡ ‡‡‡‡‡fdd„}z	|ˆjj	ƒ W d S  t
yi } zˆ |ˆ¡ W Y d }~d S d }~w ty¸ } zDˆjjru‚ ˆd ur~ˆ r~dˆ_zˆd u r‡d ‰d ‰|tƒ ƒ W n	 ty–   Y nw ddlm} ||ƒ ¡ }ˆj dd|› �¡ W Y d }~d S d }~ww )NÚExpectr^   z100-continues   HTTP/1.1 100 Continue

FÚdataÚbytesr   r/   c                   st  ˆd usJ dƒ‚ˆd usJ dƒ‚ˆd u r‚ˆ‰ˆ‰z
ˆ  d d¡\}}W n ty0   ˆd}}Y nw t|ƒ}ˆ ||¡ tƒ }ˆD ]\}}ˆ ||¡ | | ¡ ¡ q@d|v sxˆd dksxd|  krfdk sxn |d	v sxˆjd
krxd‰ ˆ dd¡ ˆ dd¡ ˆ 	¡  t
| tƒs‹J dƒ‚| r³ˆ r¥ˆj tt| ƒƒdd …  ¡ ¡ ˆj d¡ ˆj | ¡ ˆ r³ˆj d¡ ˆj ¡  d S )Nzwrite() before start_responser
   r^   zcontent-lengthr\   ÚHEADéd   éÈ   >   é0  éÌ   úHTTP/1.1TzTransfer-Encodingrn   Ú
ConnectionÚclosezapplications must write bytesé   rF   )Úsplitr>   r8   Úsend_responseÚsetÚsend_headerÚaddÚlowerÚprotocol_versionÚend_headersrw   r™   ÚwfileÚwriteÚhexrH   ÚencodeÚflush)r˜   Úcode_strÚmsgÚcodeÚheader_keysr“   r”   )Úchunk_responser’   Úheaders_sentÚheaders_setr   Ústatus_sentÚ
status_setr   r   r¬     sD   ÿ

 z*WSGIRequestHandler.run_wsgi.<locals>.writec                   sB   |rzˆ r|d   |d ¡‚W d }n	d }w ˆrtdƒ‚| ‰|‰ˆS )Nr
   r¢   zHeaders already set)Úwith_tracebackÚAssertionError)Ústatusr…   Úexc_info)rµ   r¶   r¸   r¬   r   r   Ústart_response=  s   ÿz3WSGIRequestHandler.run_wsgi.<locals>.start_responseÚappr(   c              
     sX  | ˆˆƒ}z`|D ]}ˆ|ƒ qˆsˆdƒ ˆ rˆj  d¡ W t ¡ }| ˆjtj¡ d}d}|jdd�rUˆj 	d¡}|t
|ƒ7 }|d7 }|rN|dksN|d	krOn|jdd�s4| ¡  t|d
ƒrd| ¡  d S d S t ¡ }| ˆjtj¡ d}d}|jdd�r�ˆj 	d¡}|t
|ƒ7 }|d7 }|r–|dks–|d	kr—n|jdd�s|| ¡  t|d
ƒr«| ¡  w w )Nó    s   0

r   g{®Gáz„?)Útimeouti€–˜ r
   l    d(	 iè  r¡   )r«   r¬   Ú	selectorsÚDefaultSelectorÚregisterr~   Ú
EVENT_READÚselectr-   rJ   rH   r¡   Úhasattr)r¾   Úapplication_iterr˜   ÚselectorÚ
total_sizeÚtotal_reads)r´   r’   rµ   r   r½   r¬   r   r   ÚexecuteK  sN   

€÷
ÿì÷

ÿz,WSGIRequestHandler.run_wsgi.<locals>.executeTr
   )ÚDebugTracebackrs   zError on request:
)r˜   r™   r   r/   rT   )r¾   r(   r   r/   )r…   r‰   r¨   r=   r«   r¬   r–   r’   rS   r¾   r   Úconnection_droppedÚ	ExceptionÚpassthrough_errorsÚclose_connectionr   Údebug.tbtoolsrÌ   Úrender_traceback_textr�   )r   rË   rA   rÌ   r±   r   )	r´   r’   rµ   r¶   r   r½   r·   r¸   r¬   r   Úrun_wsgiù   sD   9'€ÿ"€ìzWSGIRequestHandler.run_wsgic              
     s�   zt ƒ  ¡  W dS  ttjfy# } z|  |¡ W Y d}~dS d}~w tyG } z| jjdur;t	|ƒr;|  
d|¡ n‚ W Y d}~dS d}~ww )z/Handles a request ignoring dropped connections.NzSSL error occurred: %s)ÚsuperÚhandleÚConnectionErrorÚsocketrÀ   rÍ   rÎ   rS   ru   Úis_ssl_errorÚ	log_error)r   rA   ©Ú	__class__r   r   rÕ   Œ  s   €þ€þzWSGIRequestHandler.handleNrs   ÚBaseExceptionr’   úWSGIEnvironment | Nonec                 C  r5   )z`Called if the connection was closed by the client.  By default
        nothing happens.
        Nr   )r   rs   r’   r   r   r   rÍ   ˜  s    z%WSGIRequestHandler.connection_droppedr   r   c                   s   |  d¡r| jS ttƒ |ƒS )NÚdo_)Ú
startswithrÓ   ÚgetattrrÔ   r   rÚ   r   r   r   Ÿ  s   
zWSGIRequestHandler.__getattr__c                 C  s*   t | dd ƒr| jd S | jsdS | jd S )Nr’   rc   rY   r   )rà   r’   rv   r6   r   r   r   r�   §  s
   

z!WSGIRequestHandler.address_stringr8   c                 C  s
   | j d S )Nr
   )rv   r6   r   r   r   r‚   °  s   
zWSGIRequestHandler.port_integerc                 C  s   i | ]	}|d |d›�“qS )z\xÚ02xr   )Ú.0Úcr   r   r   Ú
<dictcomp>µ  s    zWSGIRequestHandler.<dictcomp>é    é   é    z\\ú\ri   r²   ú	int | strÚsizec                 C  sò   zt | jƒ}| j› d|› d| j› �}W n ty   | j}Y nw | | j¡}t|ƒ}|d dkr6t	|dƒ}n8|dkr;n3|dkrEt	|dƒ}n)|d dkrQt	|d	ƒ}n|d
kr[t	|dƒ}n|d dkrht	|ddƒ}nt	|ddƒ}|  
dd|||¡ d S )Nú r   Ú1ÚboldÚ200Ú304ÚcyanÚ3ÚgreenÚ404ÚyellowÚ4ÚredÚmagentaÚinfoz
"%s" %s %s)r   rt   r   r„   rŽ   ÚrequestlineÚ	translateÚ_control_char_tabler   Ú_ansi_styler�   )r   r²   rê   rt   r±   r   r   r   Úlog_request¹  s,   

þzWSGIRequestHandler.log_requestÚformatÚargsc                 G  ó   | j d|g|¢R Ž  d S )Nrs   ©r�   ©r   rþ   rÿ   r   r   r   rÙ   Ö  ó   zWSGIRequestHandler.log_errorc                 G  r   )Nrø   r  r  r   r   r   Úlog_messageÙ  r  zWSGIRequestHandler.log_messageÚtypeÚmessagec                 G  s<   |   ¡  dd¡}t||› d|  ¡ › d|› d�g|¢R Ž  d S )Nú%z%%z - - [z] Ú
)r�   rˆ   r   Úlog_date_time_string)r   r  r  rÿ   r�   r   r   r   r�   Ü  s   þýzWSGIRequestHandler.log)r   r   )r   r)   ©r   r/   rT   )rs   rÜ   r’   rÝ   r   r/   r   rO   )ri   ri   )r²   ré   rê   ré   r   r/   )rþ   r   rÿ   r   r   r/   ©r  r   r  r   rÿ   r   r   r/   )r   r   r    rP   Ú__annotations__ÚpropertyrV   r–   rÓ   rÕ   rÍ   r   r�   r‚   r   Ú	maketransÚrangerû   Úordrý   rÙ   r  r�   Ú__classcell__r   r   rÚ   r   rQ   Ÿ   s,   
 

Q ÿ

	ÿ

rQ   r”   r   Ústylesr   c                 G  sB   t s| S dddddddœ}|D ]}d|| › d	| › �} q| › d
�S )Nr
   é   rå   é!   é#   é$   )rí   rö   rò   rô   r÷   rð   z[Úmz[0m)Ú_log_add_style)r”   r  ÚcodesÚstyler   r   r   rü   æ  s   ú	
rü   Úcnú
str | Noneú2tuple[Certificate, RSAPrivateKeyWithSerialization]c           
      C  sB  z ddl m} ddlm} ddlm} ddlm} ddlm	} W n t
y,   tdƒd ‚w |ƒ }|jdd	|d
�}| d u r>d} | | |jd¡| |j| ¡g¡}|ƒ }| ¡  |¡ |¡ | ¡ ¡ | ¡ ¡ t tj¡¡ t tj¡tdd� ¡j| |j g¡dd�j| !| "| ¡| "d| › �¡g¡dd� #|| $¡ |¡}	|	|fS )Nr   )Úx509)Údefault_backend)Úhashes)Úrsa)ÚNameOIDz<Using ad-hoc certificates requires the cryptography library.i  i   )Úpublic_exponentÚkey_sizeÚbackendÚ*zDummy Certificateim  )ÚdaysF)Úcriticalz*.)%Úcryptographyr  Úcryptography.hazmat.backendsr  Úcryptography.hazmat.primitivesr   Ú)cryptography.hazmat.primitives.asymmetricr!  Úcryptography.x509.oidr"  ÚImportErrorÚ	TypeErrorÚgenerate_private_keyÚNameÚNameAttributeÚORGANIZATION_NAMEÚCOMMON_NAMEÚCertificateBuilderÚsubject_nameÚissuer_nameÚ
public_keyÚserial_numberÚrandom_serial_numberÚnot_valid_beforeÚdtÚnowr   ÚutcÚnot_valid_afterr   Úadd_extensionÚExtendedKeyUsageÚOID_SERVER_AUTHÚSubjectAlternativeNameÚDNSNameÚsignÚSHA256)
r  r  r  r   r!  r"  r%  ÚpkeyÚsubjectÚcertr   r   r   Úgenerate_adhoc_ssl_pairù  sR   ÿþÿÿþÿ

ùöórJ  Ú	base_pathÚhostútuple[str, str]c           	      C  sÒ   |dur|}t |d�\}}ddlm} | › d�}| › d�}t|dƒ�}| | |jj¡¡ W d  ƒ n1 s7w   Y  t|dƒ�}| |j|jj|j	j
| ¡ d�¡ W d  ƒ ||fS 1 s`w   Y  ||fS )	aÂ  Creates an SSL key for development.  This should be used instead of
    the ``'adhoc'`` key which generates a new cert on each server start.
    It accepts a path for where it should store the key and cert and
    either a host or CN.  If a host is given it will use the CN
    ``*.host/CN=host``.

    For more information see :func:`run_simple`.

    .. versionadded:: 0.9

    :param base_path: the path to the certificate and key.  The extension
                      ``.crt`` is added for the certificate, ``.key`` is
                      added for the key.
    :param host: the name of the host.  This can be used as an alternative
                 for the `cn`.
    :param cn: the `CN` to use.
    N)r  r   ©Úserializationz.crtz.keyÚwb©Úencodingrþ   Úencryption_algorithm)rJ  r+  rO  Úopenr¬   Úpublic_bytesÚEncodingÚPEMÚprivate_bytesÚPrivateFormatÚTraditionalOpenSSLÚNoEncryption)	rK  rL  r  rI  rG  rO  Ú	cert_fileÚ	pkey_fileÚfr   r   r   Úmake_ssl_devcert*  s*   

ÿýÿ
ÿ	÷	r_  c            
      C  s¶   ddl } ddl}tƒ \}}ddlm} | ¡ \}}| ¡ \}}|  tj|¡ |  tj|¡ t 	|| 
|jj¡¡ t 	||j|jj|jj| ¡ d�¡ t |¡ t |¡ t||ƒ}	|	S )z:Generates an adhoc SSL context for the development server.r   NrN  rQ  )ÚatexitÚtempfilerJ  r+  rO  ÚmkstemprÃ   ÚosÚremover¬   rU  rV  rW  rX  rY  rZ  r[  r¡   Úload_ssl_context)
r`  ra  rI  rG  rO  Úcert_handler\  Úpkey_handler]  Úctxr   r   r   Úgenerate_adhoc_ssl_contextV  s*   
ýþ
	

ri  r\  r]  Úprotocolú
int | Nonec                 C  s(   |du rt j}t  |¡}| | |¡ |S )aã  Loads SSL context from cert/private key files and optional protocol.
    Many parameters are directly taken from the API of
    :py:class:`ssl.SSLContext`.

    :param cert_file: Path of the certificate to use.
    :param pkey_file: Path of the private key to use. If not given, the key
                      will be obtained from the certificate file.
    :param protocol: A ``PROTOCOL`` constant from the :mod:`ssl` module.
        Defaults to :data:`ssl.PROTOCOL_TLS_SERVER`.
    N)r‹   ÚPROTOCOL_TLS_SERVERÚ
SSLContextÚload_cert_chain)r\  r]  rj  rh  r   r   r   re  t  s
   
re  rs   úException | Noner4   c                 C  s(   | du rt  tt ¡ d ¡} t| tjƒS )z?Checks if the given error (or the current one) is an SSL error.Nr
   )ÚtÚcastrÎ   rz   r¼   rw   r‹   ÚSSLError)rs   r   r   r   rØ   ‰  s   rØ   Úportr8   úsocket.AddressFamilyc                 C  s.   |   d¡rtjS d| v rttdƒrtjS tjS )zUReturn ``AF_INET4``, ``AF_INET6``, or ``AF_UNIX`` depending on
    the host and port.zunix://ú:ÚAF_INET6)rß   r×   ÚAF_UNIXrÆ   rv  ÚAF_INET)rL  rs  r   r   r   Úselect_address_family�  s
   
ry  Úfamilyútuple[str, int] | strc                 C  sb   |t krtj |  d¡d ¡S zt | ||tjtj¡}W n tj	y*   | |f Y S w |d d S )zVReturn a fully qualified socket address that can be passed to
    :func:`socket.bind`.ú://r¢   r   é   )
Úaf_unixrc  rt   ÚabspathÚ	partitionr×   ÚgetaddrinfoÚSOCK_STREAMÚIPPROTO_TCPÚgaierror)rL  rs  rz  Úresr   r   r   Úget_sockaddrš  s   ÿÿr†  c              	   C  s–   | t jkrdnd}t   | t j¡�1}z	| |df¡ W n ty3   | t jkr(dnd Y W  d  ƒ S w | ¡ d W  d  ƒ S 1 sDw   Y  dS )zˆGet the IP address of an external interface. Used when binding to
    0.0.0.0 or ::1 to show a more useful URL.

    :meta private:
    zfd31:f903:5ab5:1::1z10.253.155.219i2ã  z::1ú	127.0.0.1Nr   )r×   rv  Ú
SOCK_DGRAMÚconnectr?   Úgetsockname)rz  rL  Úsr   r   r   Úget_interface_ip«  s   ü
$úrŒ  c                      sn   e Zd ZdZdZdZeZdZ				d)d*‡ fdd„Z	d+dd„Z
d,d-‡ fd d!„Zd.‡ fd%d&„Zd/d'd(„Z‡  ZS )0rR   zuA WSGI server that that handles one request at a time.

    Use :func:`make_server` to create a server instance.
    FTNrL  r   rs  r8   r¾   r(   Úhandlerútype[WSGIRequestHandler] | NonerÏ   r4   ru   ú_TSSLContextArg | NoneÚfdrk  r   r/   c              
     s  |d u rt }dt|ƒvr| js| jrd|_|| _|| _|| _|| _t	||ƒ | _
}t|t|ƒ|ƒ}	|tkrJ|d u rJt t|	¡}	tj |	¡rJt |	¡ tƒ j|	|dd� |d u r±z
|  ¡  |  ¡  W nb ty¥ }
 z8|  ¡  t|
jtjd� |
jtj kr–td|› d�tjd� tj!dkr–|d	kr–td
tjd� t "d¡ W Y d }
~
n#d }
~
w t#y°   |  ¡  ‚ w |  ¡  t$ %||t$j&¡| _$| j$ '¡ | _(|tkrÎ| j(d | _|d urðt)|t*ƒrÜt+|Ž }n|dkrãt,ƒ }|j-| j$dd�| _$|| _.nd | _.dd l/}d|j0 1d¡› �| _2d S )Nr©   rŸ   F)Úbind_and_activate)ÚfilezPort zp is in use by another program. Either identify and stop that program, or start the server with a different port.Údarwiniˆ  zPOn macOS, try searching for and disabling 'AirPlay Receiver' in System Settings.r
   r'   T)Úserver_sider   z	Werkzeug/Úwerkzeug)3rQ   Úvarsr|   r}   r©   rL  rs  r¾   rÏ   ry  Úaddress_familyr†  r8   r~  rp  rq  r   rc  rt   ÚexistsÚunlinkrÔ   r3   Úserver_bindÚserver_activater?   Úserver_closeÚprintÚstrerrorrz   r{   ÚerrnoÚ
EADDRINUSEÚplatformÚexitrÜ   r×   Úfromfdr‚  rŠ  rƒ   rw   Útuplere  ri  Úwrap_socketru   Úimportlib.metadataÚmetadataÚversionrU   )r   rL  rs  r¾   r�  rÏ   ru   r�  r—  rƒ   rA   Ú	importlibrÚ   r   r   r3   È  sz   
ÿÿ
ý
üý€þ

zBaseWSGIServer.__init__r  r  rÿ   r   c                 G  s   t ||g|¢R Ž  d S rT   r   )r   r  r  rÿ   r   r   r   r�   /  s   zBaseWSGIServer.logç      à?Úpoll_intervalÚfloatc                   sN   z!z	t ƒ j|d� W n	 ty   Y nw W |  ¡  d S W |  ¡  d S |  ¡  w )N)r«  )rÔ   Úserve_foreverÚKeyboardInterruptrœ  )r   r«  rÚ   r   r   r­  2  s   ÿÿþzBaseWSGIServer.serve_foreverÚrequestrv   r{  c                   s   | j r‚ tƒ  ||¡S rT   )rÏ   rÔ   Úhandle_error)r   r¯  rv   rÚ   r   r   r°  :  s   zBaseWSGIServer.handle_errorc                 C  sö   d}t |ddƒ}|g}| jtkr| d| j› �¡ nW| jdu r!dnd}| j}| jdv rX| d	| j› d
�¡ | jdkrBd}ttjƒ}nd}ttj	ƒ}| d|› d|› d| j
› �¡ d|v rbd|› d�}| d|› d|› d| j
› �¡ tdd |¡ƒ dS )z<Show information about the address when starting the server.zvWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.rí   rö   z * Running on NrW   rX   >   ú::ú0.0.0.0z * Running on all addresses (ú)r²  r‡  z[::1]r|  ru  ú[ú]rø   r  )rü   r—  r~  ÚappendrL  ru   rŒ  r×   rx  rv  rs  r   Újoin)r   Údev_warningÚmessagesrx   Údisplay_hostnameÚ	localhostr   r   r   Úlog_startupB  s(   ÿ



zBaseWSGIServer.log_startup)NFNN)rL  r   rs  r8   r¾   r(   r�  rŽ  rÏ   r4   ru   r�  r�  rk  r   r/   r  )rª  )r«  r¬  r   r/   )r¯  r   rv   r{  r   r/   r
  )r   r   r    rP   r|   r}   ÚLISTEN_QUEUEÚrequest_queue_sizeÚallow_reuse_addressr3   r�   r­  r°  r¼  r  r   r   rÚ   r   rR   ½  s    ø
grR   c                   @  s   e Zd ZdZdZdZdS )ÚThreadedWSGIServerz†A WSGI server that handles concurrent requests in separate
    threads.

    Use :func:`make_server` to create a server instance.
    TN)r   r   r    rP   r|   Údaemon_threadsr   r   r   r   rÀ  e  s    rÀ  c                      s2   e Zd ZdZdZ					dd‡ fdd„Z‡  ZS )ÚForkingWSGIServerz�A WSGI server that handles concurrent requests in separate forked
    processes.

    Use :func:`make_server` to create a server instance.
    Té(   NFrL  r   rs  r8   r¾   r(   Ú	processesr�  rŽ  rÏ   r4   ru   r�  r�  rk  r   r/   c	           	   	     s.   t stdƒ‚tƒ  |||||||¡ || _d S )Nz'Your platform does not support forking.)Úcan_forkr>   rÔ   r3   Úmax_children)	r   rL  rs  r¾   rÄ  r�  rÏ   ru   r�  rÚ   r   r   r3   y  s   
zForkingWSGIServer.__init__)rÃ  NFNN)rL  r   rs  r8   r¾   r(   rÄ  r8   r�  rŽ  rÏ   r4   ru   r�  r�  rk  r   r/   )r   r   r    rP   r}   r3   r  r   r   rÚ   r   rÂ  p  s    ÷rÂ  r¾   r(   ÚthreadedrÄ  Úrequest_handlerrŽ  rÏ   ru   r�  r�  c	           	   
   C  sd   |r
|dkr
t dƒ‚|rt| ||||||d�S |dkr't| |||||||d�S t| ||||||d�S )a6  Create an appropriate WSGI server instance based on the value of
    ``threaded`` and ``processes``.

    This is called from :func:`run_simple`, but can be used separately
    to have access to the server object, such as to run it in a separate
    thread.

    See :func:`run_simple` for parameter docs.
    r
   z4Cannot have a multi-thread and multi-process server.©r�  )r>   rÀ  rÂ  rR   )	rL  rs  r¾   rÇ  rÄ  rÈ  rÏ   ru   r�  r   r   r   Úmake_server‹  s(   ÿøÿrÊ  c                   C  s   t j d¡dkS )zqCheck if the server is running as a subprocess within the
    Werkzeug reloader.

    .. versionadded:: 0.10
    ÚWERKZEUG_RUN_MAINÚtrue)rc  r’   r‰   r   r   r   r   Úis_running_from_reloader¸  s   rÍ  ÚautoÚhostnameÚapplicationÚuse_reloaderÚuse_debuggerÚ
use_evalexÚextra_filesút.Iterable[str] | NoneÚexclude_patternsÚreloader_intervalÚreloader_typeÚstatic_filesú'dict[str, str | tuple[str, str]] | Noner/   c                 C  s  t |tƒs	tdƒ‚|rddlm} |||ƒ}|r*ddlm} |||d�}|j | ¡ t	ƒ s0d}ntt
jd ƒ}t| |||
|||||d�	}|j d	¡ t| ¡ ƒt
jd< t	ƒ sb| ¡  td
tddƒƒ |r�ddlm} z||j||||	d� W | ¡  dS | ¡  w | ¡  dS )a  Start a development server for a WSGI application. Various
    optional features can be enabled.

    .. warning::

        Do not use the development server when deploying to production.
        It is intended for use only during local development. It is not
        designed to be particularly efficient, stable, or secure.

    :param hostname: The host to bind to, for example ``'localhost'``.
        Can be a domain, IPv4 or IPv6 address, or file path starting
        with ``unix://`` for a Unix socket.
    :param port: The port to bind to, for example ``8080``. Using ``0``
        tells the OS to pick a random free port.
    :param application: The WSGI application to run.
    :param use_reloader: Use a reloader process to restart the server
        process when files are changed.
    :param use_debugger: Use Werkzeug's debugger, which will show
        formatted tracebacks on unhandled exceptions.
    :param use_evalex: Make the debugger interactive. A Python terminal
        can be opened for any frame in the traceback. Some protection is
        provided by requiring a PIN, but this should never be enabled
        on a publicly visible server.
    :param extra_files: The reloader will watch these files for changes
        in addition to Python modules. For example, watch a
        configuration file.
    :param exclude_patterns: The reloader will ignore changes to any
        files matching these :mod:`fnmatch` patterns. For example,
        ignore cache files.
    :param reloader_interval: How often the reloader tries to check for
        changes.
    :param reloader_type: The reloader to use. The ``'stat'`` reloader
        is built in, but may require significant CPU to watch files. The
        ``'watchdog'`` reloader is much more efficient but requires
        installing the ``watchdog`` package first.
    :param threaded: Handle concurrent requests using threads. Cannot be
        used with ``processes``.
    :param processes: Handle concurrent requests using up to this number
        of processes. Cannot be used with ``threaded``.
    :param request_handler: Use a different
        :class:`~BaseHTTPServer.BaseHTTPRequestHandler` subclass to
        handle requests.
    :param static_files: A dict mapping URL prefixes to directories to
        serve static files from using
        :class:`~werkzeug.middleware.SharedDataMiddleware`.
    :param passthrough_errors: Don't catch unhandled exceptions at the
        server level, let the server crash instead. If ``use_debugger``
        is enabled, the debugger will still catch such errors.
    :param ssl_context: Configure TLS to serve over HTTPS. Can be an
        :class:`ssl.SSLContext` object, a ``(cert_file, key_file)``
        tuple to create a typical context, or the string ``'adhoc'`` to
        generate a temporary self-signed certificate.

    .. versionchanged:: 2.1
        Instructions are shown for dealing with an "address already in
        use" error.

    .. versionchanged:: 2.1
        Running on ``0.0.0.0`` or ``::`` shows the loopback IP in
        addition to a real IP.

    .. versionchanged:: 2.1
        The command-line interface was removed.

    .. versionchanged:: 2.0
        Running on ``0.0.0.0`` or ``::`` shows a real IP address that
        was bound as well as a warning not to run the development server
        in production.

    .. versionchanged:: 2.0
        The ``exclude_patterns`` parameter was added.

    .. versionchanged:: 0.15
        Bind to a Unix socket by passing a ``hostname`` that starts with
        ``unix://``.

    .. versionchanged:: 0.10
        Improved the reloader and added support for changing the backend
        through the ``reloader_type`` parameter.

    .. versionchanged:: 0.9
        A command-line interface was added.

    .. versionchanged:: 0.8
        ``ssl_context`` can be a tuple of paths to the certificate and
        private key files.

    .. versionchanged:: 0.6
        The ``ssl_context`` parameter was added.

    .. versionchanged:: 0.5
       The ``static_files`` and ``passthrough_errors`` parameters were
       added.
    zport must be an integerr
   )ÚSharedDataMiddleware)ÚDebuggedApplication)ÚevalexNÚWERKZEUG_SERVER_FDrÉ  Trø   zPress CTRL+C to quitrô   )Úrun_with_reloader)rÔ  rÖ  ÚintervalrØ  )rw   r8   r/  Úmiddleware.shared_datarÛ  ÚdebugrÜ  Útrusted_hostsr¶  rÍ  rc  r’   rÊ  r×   Úset_inheritabler   Úfilenor¼  r   rü   Ú	_reloaderrß  r­  rœ  )rÏ  rs  rÐ  rÑ  rÒ  rÓ  rÔ  rÖ  r×  rØ  rÇ  rÄ  rÈ  rÙ  rÏ   ru   rÛ  rÜ  r�  Úsrvrß  r   r   r   Ú
run_simpleÁ  sP   
p
÷ûrè  )r”   r   r  r   r   r   rT   )r  r  r   r  )NN)rK  r   rL  r  r  r  r   rM  )r   r&   )r\  r   r]  r  rj  rk  r   r&   )rs   ro  r   r4   )rL  r   rs  r8   r   rt  )rL  r   rs  r8   rz  rt  r   r{  )rz  rt  r   r   )Fr
   NFNN)rL  r   rs  r8   r¾   r(   rÇ  r4   rÄ  r8   rÈ  rŽ  rÏ   r4   ru   r�  r�  rk  r   rR   rN   )FFTNNr
   rÎ  Fr
   NNFN)"rÏ  r   rs  r8   rÐ  r(   rÑ  r4   rÒ  r4   rÓ  r4   rÔ  rÕ  rÖ  rÕ  r×  r8   rØ  r   rÇ  r4   rÄ  r8   rÈ  rŽ  rÙ  rÚ  rÏ   r4   ru   r�  r   r/   )RrP   Ú
__future__r   rŸ  Úiorc  rÁ   r×   Úsocketserverrz   Útypingrp  r   r<  r   r   Úhttp.serverr   r   Úurllib.parser   r	   Ú	_internalr   r   Ú
exceptionsr   rW   r   Úurlsr   r‹   rÖ   rÀ   ÚSSLEOFErrorr   r  r.  r   r  r   Ú
__import__rÆ   rÅ  r$   rw  r~  rŽ   r½  ÚOptionalÚUnionr¤  r   ÚLiteralÚ_TSSLContextArgÚTYPE_CHECKINGÚ_typeshed.wsgir(   r)   Ú-cryptography.hazmat.primitives.asymmetric.rsar*   Úcryptography.x509r+   Ú	RawIOBaser,   rQ   rü   rJ  r_  ri  re  rØ   ry  r†  rŒ  rR   ÚThreadingMixInrÀ  rÂ  rÊ  rÍ  rè  r   r   r   r   Ú<module>   sÈ    ýö
ÿ

ÿ"ÿ>  
Iÿ2ÿ
,ÿ



 )÷
-ð