
    i                        % S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
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  SSKJr  SSKJr  SSKJr  SSKJr   SSKr\ \RB                  \RD                  4r#S\$S'   Sr'\RP                  S:X  a	   \)" S5        \*" \S5      r+\+(       a  \RX                  r,O
 " S S5      r, \RZ                  r.Sr0\Rb                  \Rd                  S\3\4\Rb                  \4   4   \Rj                  S   4      r6\Rn                  (       a  SSK8J9r9  SS K8J:r:  SS!K;J<r<  SS"K=J>r>   " S# S$\R~                  5      r@ " S% S&\5      rAS9S' jrB S:   S;S( jjrC S<       S=S) jjrDS>S* jrE S<       S?S+ jjrFS:S@S, jjrGSAS- jrH        SBS. jrISCS/ jrJ " S0 S1\5      rK " S2 S3\R                  \K5      rM " S4 S5\,\K5      rN      SD                   SES6 jjrOSFS7 jrP             SG                                 SHS8 jjrQg! \% a#     " S S5      r&\&" 5       r\ \RB                  4r# GNf = f! \% a    Sr' GNf = f! \/ a    Sr. GNf = f)Ia  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                      \ rS rSrSS jrSrg)	_SslDummy1   c                    [        S5      e)NzUSSL is unavailable because this Python runtime was not compiled with SSL/TLS support.)RuntimeError)selfnames     ;/app/.venv/lib/python3.13/site-packages/werkzeug/serving.py__getattr___SslDummy.__getattr__2   s    2      Nr   strreturnt.Any)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   1   s    	r   r   TntcoloramaFforkc                      \ rS rSrSrg)ForkingMixInI   r   N)r#   r$   r%   r&   r'   r   r   r   r,   r,   I   s    r   r,      ssl.SSLContextadhoc)WSGIApplication)WSGIEnvironment)RSAPrivateKeyWithSerialization)Certificatec                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)DechunkedInputa   z8An input stream that handles Transfer-Encoding 'chunked'c                ,    Xl         SU l        SU l        g )NFr   )_rfile_done_len)r   rfiles     r   __init__DechunkedInput.__init__d   s    
	r   c                    g)NTr   r   s    r   readableDechunkedInput.readablei   s    r   c                     U R                   R                  5       R                  S5      n[        UR	                  5       S5      nUS:  a  [        S5      eU$ ! [
         a  n[        S5      UeS nAff = f)Nlatin1   zInvalid chunk headerr   z!Negative chunk length not allowed)r9   readlinedecodeintstrip
ValueErrorOSError)r   liner;   es       r   read_chunk_lenDechunkedInput.read_chunk_lenl   sp    	9;;'')00:Dtzz|R(D !8=>>	  	901q8	9s   AA 
A3"A..A3c                   SnU R                   (       Gdx  U[        U5      :  Gah  U R                  S:X  a  U R                  5       U l        U R                  S:X  a  SU l         U R                  S:  a  [	        [        U5      U R                  5      nX#-   [        U5      :  aV  U R
                  R                  [        U5      U-
  5      XS & U =R                  [        U5      U-
  -  sl        [        U5      nO8U R
                  R                  U5      XX#-   & U =R                  U-  sl        X#-  nU R                  S:X  a+  U R
                  R                  5       nUS;  a  [        S5      eU R                   (       d  U[        U5      :  a  GMh  U$ )Nr   T)   
   
   z!Missing chunk terminating newline)	r:   lenr;   rN   minr9   readrF   rK   )r   bufrV   n
terminators        r   readintoDechunkedInput.readintov   s:   ***CyyA~ !//1	yyA~ "
yy1} C$)),
 8c#h&!%!1!1#c(T/!BCJIISD0Is8D+/;;+;+;A+>Ctx(IINIIDyyA~ "[[113
%<<!"EFFE **CH r   )r:   r;   r9   N)r<   zt.IO[bytes]r!   Noner!   boolr!   rH   )rW   	bytearrayr!   rH   )
r#   r$   r%   r&   __doc__r=   rA   rN   rZ   r'   r   r   r   r6   r6   a   s    B
&r   r6   c            
      b  ^ \ rS rSr% SrS\S'   \SS j5       rSS jrSS jr	SU4S jjr
 S     SS	 jjrSU4S
 jjrSS jrSS jr\R!                  / \" S5      Q\" SS5      Q V Vs0 s H	  oSUS 3_M     snn 5      rS\\" S5      '   S S!S jjrS"S jrS"S jrS#S jrSrU=r$ s  snn f )$WSGIRequestHandler   z3A request handler that implements WSGI dispatching.BaseWSGIServerserverc                .    U R                   R                  $ N)rf   _server_versionr@   s    r   server_version!WSGIRequestHandler.server_version   s    {{***r   c                   [        U R                  5      nU R                  R                  c  SOSnU R                  (       d  SU l        O2[        U R                  [        5      (       a  U R                  S4U l        UR                  (       d-  UR                  (       a  SUR                   UR                   3nOUR                  n[        U5      n0 SS_SU_S	U R                  _S
[        R                  _SU R                  R                  _SU R                  R                  _SS_SU R                  _SU R                   _SU R"                  _SS_S[%        U5      _S[%        UR&                  5      _S[%        U R                  5      _S[%        U R                  5      _SU R)                  5       _SU R+                  5       _U R                  R,                  S   [        U R                  R,                  S   5      U R.                  S.EnU R0                  R3                  5        H\  u  pVSU;   a  M  UR5                  5       R7                  SS5      nUR7                  SS5      nUS;  a  S U 3nXT;   a	  XE    S!U 3nXdU'   M^     S"[9        UR;                  S#5      5      ;   a  S$US%'   [=        US	   5      US	'   UR                  (       a   UR                  (       a  UR                  US&'    U R                  R?                  S$S'9nUb  [@        RB                  " U5      US('   U$ ! [D         a     U R                  RG                  S)S*5         U$ [H         a     U$ f = f)+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
   pathrf   ssl_contextclient_address
isinstancer    schemenetlocr	   r<   sysstderrmultithreadmultiprocess
connectionrj   commandr   queryaddress_stringport_integerserver_addressrequest_versionheadersitemsupperreplacer   getr6   getpeercertsslDER_cert_to_PEM_certrJ   logAttributeError)r   request_url
url_scheme	path_infoenvironkeyvalue	peer_certs           r   make_environWSGIRequestHandler.make_environ   sg   tyy)#{{66>VG
"""0D++S11#'#6#6":D
 !!k&8&8K../0@0@/ABI#((II&	$
F$
z$
 $**$
 3::	$

  7 7$
  !9!9$
 U$
 t$
 t22$
 dll$
 2$
 -i8$
 01B1BC$
 /		:$
" +DII6#$
$ 4..0%$
& 4,,.'$
(  ;;55a8t{{99!<=#33-$
2 ,,,,.JCcz))+%%c3/CMM&"-E<<cUm>&|nAeW5E CL / (5M)NOO/3G+,$27<3H$IGL! +"4"4#.#5#5GK 	 333EI$-0-E-Ei-P)*   	OKKOOG%MN
 	  			s   )5L   &M		MMc                $  ^ ^^^^^	^
^^ T R                   R                  SS5      R                  5       R                  5       S:X  a  T R                  R                  S5        T R                  5       =T l        mS mS mS m
S mSmSUUUUU U
U4S jjmSUUUU4S jjm	SUUUU U	U4S jjn U" T R                  R                  5        g ! [         a  nT R                  UT5         S nAg S nAf[         a  nT R                  R                  (       a  e T
b  T(       a  S	T l         T
c  S mS mU" [        5       5        O! [         a     Of = fS
SKJn  U" U5      R%                  5       nT R                  R'                  SSU 35         S nAg S nAff = f)NExpectrt   z100-continues   HTTP/1.1 100 Continue

Fc                  > Tc   S5       eT
c   S5       eTc  TmT
m	 TR                  S S5      u  p[        U5      nTR                  X25        [	        5       nT	 H5  u  pVTR                  XV5        UR                  UR                  5       5        M7     SU;   dB  TS   S:X  d9  SUs=::  a  S:  d,  O  US	;   d$  TR                  S
:  a  SmTR                  SS5        TR                  SS5        TR                  5         [        U [        5      (       d   S5       eU (       a  T(       aY  TR                  R                  [        [        U 5      5      SS  R!                  5       5        TR                  R                  S5        TR                  R                  U 5        T(       a  TR                  R                  S5        TR                  R#                  5         g ! [         a    TSp! GNf = f)Nzwrite() before start_responser   rt   zcontent-lengthrr   HEADd      >   0     HTTP/1.1TzTransfer-Encodingr   
Connectionclosezapplications must write bytes   rR   )splitrJ   rH   send_responsesetsend_headeraddlowerprotocol_versionend_headersr   byteswfilewritehexrT   encodeflush)datacode_strmsgcodeheader_keysr   r   chunk_responser   headers_sentheaders_setr   status_sent
status_sets          r   r   *WSGIRequestHandler.run_wsgi.<locals>.write  s   )J+JJ)*K,KK*"(*4$/$5$5dA$>MH 8}""4-!e".JC$$S0OOCIIK0 #/ )K7"#34>4-#-:---;%)N$$%8)D   w7  "dE**K,KK*!JJ$$ST^AB%7%>%>%@AJJ$$W-

  &!JJ$$W-JJ] " 4$/c4s   G G)(G)c                   > U(       a#   T(       a  US   R                  US   5      e S nOT(       a  [        S5      eU mUmT$ ! S nf = f)Nr   r   zHeaders already set)with_tracebackAssertionError)statusr   exc_infor   r   r   r   s      r   start_response3WSGIRequestHandler.run_wsgi.<locals>.start_response=  sZ    $#&qk88!EE $  $H$%:;;J!KL  $Hs   A Ac                ,  > U " TT
5      n U H  nT" U5        M     T(       d  T" S5        T(       a  T	R                   R                  S5        [        R                  " 5       nUR	                  T	R
                  [        R                  5        SnSnUR                  SS9(       aX  T	R                  R                  S5      nU[        U5      -  nUS-  nU(       a  US:  d  US	:  a  OUR                  SS9(       a  MX  UR                  5         [        US
5      (       a  UR                  5         g g ! [        R                  " 5       nUR	                  T	R
                  [        R                  5        SnSnUR                  SS9(       aX  T	R                  R                  S5      nU[        U5      -  nUS-  nU(       a  US:  d  US	:  a  OUR                  SS9(       a  MX  UR                  5         [        US
5      (       a  UR                  5         f f = f)Nr   s   0

r   g{Gz?)timeouti r   l    d(	 i  r   )r   r   	selectorsDefaultSelectorregisterr   
EVENT_READselectr<   rV   rT   r   hasattr)appapplication_iterr   selector
total_sizetotal_readsr   r   r   r   r   r   s         r   execute,WSGIRequestHandler.run_wsgi.<locals>.executeK  s   "7N;#-,D$K -##J!JJ$$\2 %446!!$//93G3GH
 oodo3::??:6D#d)+J1$K  :#?;QUCU oodo33  +W55$**, 6) %446!!$//93G3GH
 oodo3::??:6D#d)+J1$K  :#?;QUCU oodo33  +W55$**, 6s   AD0 0B.H 3HTr   )DebugTracebackr   zError on request:
)r   r   r!   r\   rh   )r   r1   r!   r\   )r   r   r   rI   r   r   r   r   rf   r   r   connection_dropped	Exceptionpassthrough_errorsclose_connectionr   debug.tbtoolsr   render_traceback_textr   )r   r   rM   r   r   r   r   r   r   r   r   r   r   s   `    @@@@@@@@r   run_wsgiWSGIRequestHandler.run_wsgi   s^   <<Hb)//1779^KJJ=>!%!2!2!44w!%
48"&59$7	 7	r	 	%	- %	-N	BDKKOO$( 	0##Aw// 	B{{--&>(,% &!%J"&K+-.  6 #99;CKKOOG':3%%@AA)	BsH   )C 
FC''F4-F
"D:9F
:
EF
E>F

Fc                ,  >  [         TU ]  5         g! [        [        R                  4 a  nU R                  U5         SnAgSnAf[         aD  nU R                  R                  b'  [        U5      (       a  U R                  SU5         SnAge SnAff = f)z/Handles a request ignoring dropped connections.NzSSL error occurred: %s)superhandleConnectionErrorsocketr   r   r   rf   r   is_ssl_error	log_error)r   rM   	__class__s     r   r   WSGIRequestHandler.handle  sr    	GN0 	'##A&& 	{{&&2|A7;;		s&    BAB9BBBc                    g)zPCalled if the connection was closed by the client.  By default
nothing happens.
Nr   )r   r   r   s      r   r   %WSGIRequestHandler.connection_dropped  s    r   c                p   > UR                  S5      (       a  U R                  $ [        [        5       U5      $ )Ndo_)
startswithr   getattrr   )r   r   r   s     r   r   WSGIRequestHandler.__getattr__  s-    ??5!!==  uw%%r   c                    [        U SS 5      (       a  U R                  S   $ U R                  (       d  gU R                  S   $ )Nr   ry   ro   r   )r   r   r   r@   s    r   r   !WSGIRequestHandler.address_string  s=    4D))<<..""""1%%r   c                     U R                   S   $ )Nr   )r   r@   s    r   r   WSGIRequestHandler.port_integer  s    ""1%%r             z\x02xz\\\c                    [        U R                  5      nU R                   SU SU R                   3nUR                  U R                  5      n[        U5      nUS   S:X  a  [        US5      nOgUS:X  a  O`US:X  a  [        US5      nOMUS   S:X  a  [        US	5      nO7US
:X  a  [        US5      nO$US   S:X  a  [        USS5      nO[        USS5      nU R                  SSXAU5        g ! [         a    U R
                  n Nf = f)N r   1bold200304cyan3green404yellow4redmagentainfoz
"%s" %s %s)r   r   r   r   r   requestline	translate_control_char_tabler    _ansi_styler   )r   r   sizer   r   s        r   log_requestWSGIRequestHandler.log_request  s   	#dii(D\\N!D64+?+?*@AC mmD4454y7c>c6*CU]U]c6*C!W^c7+CU]c8,C!W^c651Cc695Cs$7/  	#""C	#s   3C- -DDc                ,    U R                   " SU/UQ76   g )Nr   r   r   formatargss      r   r   WSGIRequestHandler.log_error  s    &(4(r   c                ,    U R                   " SU/UQ76   g )Nr  r"  r#  s      r   log_messageWSGIRequestHandler.log_message  s    '$'r   c           	         U R                  5       R                  SS5      n[        UU SU R                  5        SU S3/UQ76   g )N%z%%z - - [z] 
)r   r   r   log_date_time_string)r   typemessager%  r   s        r   r   WSGIRequestHandler.log  sS    ,,.66sDAfT%>%>%@$AG9BO	
 	
r   )r   r   r   )r!   r    )r!   r2   r!   r\   rh   )r   BaseExceptionr   zWSGIEnvironment | Noner!   r\   r   r_   )r   r   )r   	int | strr  r3  r!   r\   )r$  r    r%  r"   r!   r\   r.  r    r/  r    r%  r"   r!   r\   )r#   r$   r%   r&   ra   __annotations__propertyrj   r   r   r   r   r   r   r   r    	maketransranger  ordr  r   r(  r   r'   __classcell__).0cr   s   00@r   rc   rc      s    =+ +ObQBf
 GK"-C	&&& --#EU4[#E5t3D#EF#Ear!CM	#EF &+D	"8:)(
 
O 	Gs   ,B+
rc   c                ^    [         (       d  U $ SSSSSSS.nU H  nSX#    S	U  3n M     U  S
3$ )Nr      r  !   #   $   )r  r  r  r  r  r  z[mz[0m)_log_add_style)r   stylescodesstyles       r   r  r    sV    > E ~Qug.  WGr   c           	         SSK Jn  SSKJn  SSKJn  SSKJn  SSKJ	n  U" 5       nUR                  SS	US
9nU c  Sn UR                  UR                  UR                  S5      UR                  UR                   U 5      /5      nU" 5       nUR#                  5       R%                  U5      R'                  U5      R)                  UR)                  5       5      R+                  UR-                  5       5      R/                  [0        R2                  " [4        R6                  5      5      R9                  [0        R2                  " [4        R6                  5      [;        SS9-   5      R=                  UR?                  UR@                  /5      SS9R=                  URC                  URE                  U 5      URE                  SU  35      /5      SS9RG                  XsRI                  5       U5      n	X4$ ! [         a    [        S5      S ef = f)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*.)%cryptographyrH  cryptography.hazmat.backendsrI  cryptography.hazmat.primitivesrJ  )cryptography.hazmat.primitives.asymmetricrK  cryptography.x509.oidrL  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)
cnrH  rI  rJ  rK  rL  rO  pkeysubjectcerts
             r   generate_adhoc_ssl_pairru    s   	%@9A1 G##g $ D
 
ziiw88:MNw22B7	
G G!	g		W		DOO%	&	t002	3		"&&.	/	-	s0CC	D	t,,d.B.B-CDu	U	''b)94<<"RD	;R(ST 
 

 
dMMOW	- 	 :K  J
	s   G( (G?c           	        Ub  Un[        US9u  p4SSKJn  U  S3nU  S3n[        US5       nUR	                  UR                  UR                  R                  5      5        SSS5        [        US5       nUR	                  UR                  UR                  R                  UR                  R                  UR                  5       S95        SSS5        Xg4$ ! , (       d  f       N|= f! , (       d  f       Xg4$ = f)	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)rq  r   serializationz.crtz.keywbencodingr$  encryption_algorithm)ru  rU  rx  openr   public_bytesEncodingPEMprivate_bytesPrivateFormatTraditionalOpenSSLNoEncryption)		base_pathhostrq  rt  rr  rx  	cert_file	pkey_filefs	            r   make_ssl_devcertr  *  s    * (B/JD<+T"I+T"I	i	!	!!-"8"8"<"<=> 
	i	!	&//33$22EE%2%?%?%A  	
 
  
			 s   5C6AC)
C&)
C9c            	        SSK n SSKn[        5       u  p#SSKJn  UR                  5       u  pVUR                  5       u  pxU R                  [        R                  U5        U R                  [        R                  U5        [        R                  " XRR                  UR                  R                  5      5        [        R                  " UUR                  UR                  R                  UR                  R                  UR!                  5       S95        [        R"                  " U5        [        R"                  " U5        [%        Xh5      n	U	$ )z:Generates an adhoc SSL context for the development server.r   Nrw  rz  )atexittempfileru  rU  rx  mkstempr   osremover   r~  r  r  r  r  r  r  r   load_ssl_context)
r  r  rt  rr  rx  cert_handler  pkey_handler  ctxs
             r   generate_adhoc_ssl_contextr  V  s    (*JD<%--/K%--/K
OOBIIy)
OOBIIy)HH[++M,B,B,F,FGHHH"++// ..AA!.!;!;!= 	 	
 HH[HH[
9
0CJr   c                z    Uc  [         R                  n[         R                  " U5      nUR                  X5        U$ )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`.
)r   PROTOCOL_TLS_SERVER
SSLContextload_cert_chain)r  r  protocolr  s       r   r  r  t  s6     **
..
"C	-Jr   c                    U c1  [         R                  " [        [        R                  " 5       S   5      n [        U [        R                  5      $ )z?Checks if the given error (or the current one) is an SSL error.r   )tcastr   r   r   r   r   SSLError)r   s    r   r   r     s3    }y#,,."34eS\\**r   c                    U R                  S5      (       a  [        R                  $ SU ;   a%  [        [        S5      (       a  [        R                  $ [        R
                  $ )zQReturn ``AF_INET4``, ``AF_INET6``, or ``AF_UNIX`` depending on
the host and port.zunix://:AF_INET6)r   r   AF_UNIXr   r  AF_INET)r  ports     r   select_address_familyr    sD     y!!~~	44>>r   c                .   U[         :X  a1  [        R                  R                  U R	                  S5      S   5      $  [
        R                  " XU[
        R                  [
        R                  5      nUS   S   $ ! [
        R                   a    X4s $ f = f)zRReturn a fully qualified socket address that can be passed to
:func:`socket.bind`.://r   r      )
af_unixr  r   abspath	partitionr   getaddrinfoSOCK_STREAMIPPROTO_TCPgaierror)r  r  familyress       r   get_sockaddrr    s    
 wwt~~e4Q788   2 2F4F4F

 q6!9 ?? zs   5A: :BBc                b   U [         R                  :X  a  SOSn[         R                   " U [         R                  5       n UR                  US45        UR                  5       S   sSSS5        $ ! [         a$    U [         R                  :X  a  SOSs sSSS5        $ f = f! , (       d  f       g= f)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   r  
SOCK_DGRAMconnectrK   getsockname)r  r  ss      r   get_interface_ipr    s     %+foo$= CSD	vv00	1Q	GIItUm$ }}q! 
2	1  	G"foo55;F	 
2	1	G 
2	1s/   B  A/B /"BB BB  
B.c                     ^  \ rS rSrSrSrSr\rSr	    S               SU 4S jjjr
SS jrSSU 4S jjjr      SU 4S jjrSS	 jrS
rU =r$ )re   i  zmA WSGI server that that handles one request at a time.

Use :func:`make_server` to create a server instance.
FTc                  > Uc  [         nS[        U5      ;  a)  U R                  (       d  U R                  (       a  SUl        Xl        X l        X0l        XPl        [        X5      =U l
        n[        U[        U5      U5      n	U[        :X  aX  UcU  [        R                  " [         U	5      n	["        R$                  R'                  U	5      (       a  ["        R(                  " U	5        [*        TU ]Y  U	USS9  Uc"   U R/                  5         U R1                  5         OYU R5                  5         [H        RJ                  " Xx[H        RL                  5      U l$        U RH                  RO                  5       U l(        U[        :w  a  U RP                  S   U l        UbT  [S        U[T        5      (       a	  [W        U6 nOUS:X  a
  [Y        5       nUR[                  U RH                  SS9U l$        X`l.        OS U l.        SS K/nSUR`                  Rc                  S5       3U l2        g ! [2         a  n
U R5                  5         [7        U
R8                  [:        R<                  S9  U
R>                  [>        R@                  :X  aN  [7        SU S3[:        R<                  S9  [:        RB                  S:X  a  US	:X  a  [7        S
[:        R<                  S9  [:        RD                  " S5         S n
A
GNhS n
A
f[F         a    U R5                  5         e f = f)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   r0   T)server_sider   z	Werkzeug/werkzeug)3rc   varsr   r   r   r  r  r   r   r  address_familyr  rH   r  r  r  r    r  r   existsunlinkr   r=   server_bindserver_activaterK   server_closeprintstrerrorr   r   errno
EADDRINUSEplatformexitr2  r   fromfdr  r  r   r   tupler  r  wrap_socketr   importlib.metadatametadataversionri   )r   r  r  r   handlerr   r   fdr  r   rM   	importlibr   s               r   r=   BaseWSGIServer.__init__  st    ?(G
 T']2 1 1'1G$		"4/DT/PPn%dCI~F W$VVC8Nww~~n--		.) 	# 	 	
 :  "$$&:  !--F<N<NODK"&++"9"9";DW$++A.DI"+u--.<'8:%11$++41PDK6A#D!!*9+=+=+E+Ej+Q*RSg   !!#ajjszz277e...v &! ! !ZZ	 ||x/DDLF!$   !!#s   8 H 
K9 B4KK9c                    [        X/UQ76   g rh   r   )r   r.  r/  r%  s       r   r   BaseWSGIServer.log/  s    T"T"r   c                   >  [         TU ]  US9  U R                  5         g ! [         a     Nf = f! U R                  5         f = f)N)poll_interval)r   serve_foreverKeyboardInterruptr  )r   r  r   s     r   r  BaseWSGIServer.serve_forever2  sI    	 G!!>  ! 		 s   ! 
.1 .1 Ac                F   > U R                   (       a  e [        TU ]	  X5      $ rh   )r   r   handle_error)r   requestr   r   s      r   r  BaseWSGIServer.handle_error:  s!     ""w#G<<r   c                   Sn[        USS5      nU/nU R                  [        :X  a  UR                  SU R                   35        OU R
                  c  SOSnU R                  nU R                  S;   a  UR                  S	U R                   S
35        U R                  S:X  a  Sn[        [        R                  5      nOSn[        [        R                  5      nUR                  SU SU SU R                   35        SU;   a  SU S3nUR                  SU SU SU R                   35        [        SSR                  U5      5        g)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 Nrm   rn   >   ::0.0.0.0z * Running on all addresses ()r  r  z[::1]r  r  []r  r,  )r  r  r  appendr  r   r  r   r  r  r  r   join)r   dev_warningmessagesr   display_hostname	localhosts         r   log_startupBaseWSGIServer.log_startupB  s5   A 	 "+vu==')OOnTYYK89#//7VWF#yyyy--"?		{! LM99	) +I'7'G$ 'I'7'H$.I;a		{ ST&&%&'7&8#: OOnVHC8H7I499+VWVTYYx()r   )	ri   r  r   r  r   r  r   r   r   )NFNN)r  r    r  rH   r   r1   r  type[WSGIRequestHandler] | Noner   r^   r   _TSSLContextArg | Noner  
int | Noner!   r\   r4  )g      ?)r  floatr!   r\   )r  r"   r   tuple[str, int] | strr!   r\   r1  )r#   r$   r%   r&   ra   r   r   LISTEN_QUEUErequest_queue_sizeallow_reuse_addressr=   r   r  r  r  r'   r:  r   s   @r   re   re     s    
 KL% 48#(.2eTeT eT 	eT
 1eT !eT ,eT eT 
eT eTN#   ==.C=	= *  *r   re   c                       \ rS rSrSrSrSrSrg)ThreadedWSGIServerie  zzA WSGI server that handles concurrent requests in separate
threads.

Use :func:`make_server` to create a server instance.
Tr   N)r#   r$   r%   r&   ra   r   daemon_threadsr'   r   r   r   r  r  e  s     KNr   r  c                  d   ^  \ rS rSrSrSr     S                 SU 4S jjjrSrU =r$ )ForkingWSGIServerip  zA WSGI server that handles concurrent requests in separate forked
processes.

Use :func:`make_server` to create a server instance.
Tc	           	     b   > [         (       d  [        S5      e[        T	U ]  XX5XgU5        X@l        g )Nz'Your platform does not support forking.)can_forkrJ   r   r=   max_children)
r   r  r  r   	processesr  r   r   r  r   s
            r   r=   ForkingWSGIServer.__init__y  s1     xFGGS3ETVW%r   )r  )(   NFNN)r  r    r  rH   r   r1   r  rH   r  r  r   r^   r   r  r  r  r!   r\   )	r#   r$   r%   r&   ra   r   r=   r'   r:  r  s   @r   r  r  p  s     L 37#(.2&& & 	&
 & 1& !& ,& & 
& &r   r  c	                    U(       a  US:  a  [        S5      eU(       a  [        XX%XgUS9$ US:  a  [        U UUUUUUUS9$ [        XX%XgUS9$ )a  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  )rJ   r  r  re   )	r  r  r   threadedr  request_handlerr   r   r  s	            r   make_serverr	    s{    ( IMOPP!.@RT
 	
 1} 	
 		
 C*<b r   c                 F    [         R                  R                  S5      S:H  $ )zeCheck if the server is running as a subprocess within the
Werkzeug reloader.

.. versionadded:: 0.10
WERKZEUG_RUN_MAINtrue)r  r   r   r   r   r   is_running_from_reloaderr    s     ::>>-.&88r   c                   [        U[        5      (       d  [        S5      eU(       a  SSKJn  U" X-5      nU(       a'  SSKJn  U" X%S9nUR                  R                  U 5        [        5       (       d  SnO[        [        R                  S   5      n[        U UUU
UUUUUS9	nUR                  R                  S	5        [        UR!                  5       5      [        R                  S'   [        5       (       d&  UR#                  5         [%        S
['        SS5      5        U(       a,  SSKJn   U" UR,                  UUUU	S9  UR/                  5         gUR-                  5         g! UR/                  5         f = f)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)extra_filesexclude_patternsintervalreloader_type)r   rH   rY  middleware.shared_datar  debugr  trusted_hostsr  r  r  r   r	  r   set_inheritabler    filenor  r   r  	_reloaderr  r  r  )hostnamer  applicationuse_reloaderuse_debugger
use_evalexr  r  reloader_intervalr  r  r  r  static_filesr   r   r  r  r  srvr  s                        r   
run_simpler&    s@   ` dC  122@*;E.)+I 	!!((2#%%012

C JJt$'*3::<'8BJJ#$#%%V[!7BC0		!!'!1*+  s   +E! !E3)r   r    rD  r    r!   r    rh   )rq  
str | Noner!   z2tuple[Certificate, RSAPrivateKeyWithSerialization])NN)r  r    r  r'  rq  r'  r!   ztuple[str, str])r!   r/   )r  r    r  r'  r  r  r!   r/   )r   zException | Noner!   r^   )r  r    r  rH   r!   socket.AddressFamily)r  r    r  rH   r  r(  r!   r  )r  r(  r!   r    )Fr   NFNN)r  r    r  rH   r   r1   r  r^   r  rH   r  r  r   r^   r   r  r  r  r!   re   r]   )FFTNNr   autoFr   NNFN)"r  r    r  rH   r  r1   r   r^   r!  r^   r"  r^   r  t.Iterable[str] | Noner  r*  r#  rH   r  r    r  r^   r  rH   r  r  r$  z'dict[str, str | tuple[str, str]] | Noner   r^   r   r  r!   r\   )Rra   
__future__r   r  ior  r   r   socketserverr   typingr  r   rf  r   r   http.serverr   r   urllib.parser	   r
   	_internalr   r   
exceptionsr   rm   r   urlsr   r   r   r   SSLEOFErrorr   r5  rX  r   rC  r   
__import__r   r   r,   r  r  r   r  OptionalUnionr  r    Literal_TSSLContextArgTYPE_CHECKING_typeshed.wsgir1   r2   -cryptography.hazmat.primitives.asymmetric.rsar3   cryptography.x509r4   	RawIOBaser6   rc   r  ru  r  r  r  r   r  r  r  re   ThreadingMixInr  r  r	  r  r&  r   r   r   <module>r@     s   #  	 	    
  #   . "   !  + + " B 	>: " 77d?: 2v,,L nnG **GGeCC$89199W;MMN ??.. .;R\\ ;|D
/ D
N
( ..7.d ?C) ) $) 1;) ) X> JN)<F*+
"6""$e*Z e*P44n &n &> 7;$*.*
*
* 
* 	*
 * 5* * (* 	* *Z9 *./37;<@$*.!ee
e !e 	e
 e e (e -e e e e e 5e :e e  (!e" 
#ee  
B  +C!0&.. A
B"    Gs6   3"I (I2 J %I/.I/2I>=I>JJ