
     fk                       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Zn"# e$ r  G d d          Z e            ZY nw xY wdZ ej!        dk    r	  e"d           n# e$ r dZ Y nw xY w e#ed          Z$e$rej%        Z%n G d d          Z%	 ej&        Z'n# e($ r dZ'Y nw xY wdZ)ej*        ej+        dej,        e-ej*        e-         f         ej.        d         f                  Z/ej0        rddl1m2Z2 ddl1m3Z3 ddl4m5Z5 ddl6m7Z7  G d  d!ej8                  Z9 G d" d#e          Z:ddd(Z;	 dedfd,Z<	 dgdhd0Z=did1Z>	 dgdjd6Z?dedkd:Z@dld>ZAdmdAZBdndBZC G dC dDe          ZD G dE dFejE        eD          ZF G dG dHe%eD          ZG	 	 	 	 	 	 dodpdSZHdqdTZI	 	 	 	 	 	 	 	 	 	 	 	 	 drdsdcZJdS )ta  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)
uri_to_iric                      e Zd ZddZdS )	_SslDummynamestrreturnt.Anyc                     t          d          )NzUSSL is unavailable because this Python runtime was not compiled with SSL/TLS support.)RuntimeError)selfr   s     S/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/werkzeug/serving.py__getattr__z_SslDummy.__getattr__+   s    2      Nr   r   r   r   )__name__
__module____qualname__r    r   r   r   r   *   s(        	 	 	 	 	 	r   r   TntcoloramaFforkc                      e Zd ZdS )ForkingMixInN)r   r   r    r!   r   r   r&   r&   A   s        r   r&      ssl.SSLContextadhoc)WSGIApplication)WSGIEnvironment)RSAPrivateKeyWithSerialization)Certificatec                  2    e Zd ZdZddZddZdd
ZddZdS )DechunkedInputz8An input stream that handles Transfer-Encoding 'chunked'rfilet.IO[bytes]r   Nonec                0    || _         d| _        d| _        d S )NFr   )_rfile_done_len)r   r0   s     r   __init__zDechunkedInput.__init__\   s    
			r   boolc                    dS )NTr!   r   s    r   readablezDechunkedInput.readablea   s    tr   intc                   	 | j                                                             d          }t          |                                d          }n"# t
          $ r}t          d          |d }~ww xY w|dk     rt          d          |S )Nlatin1   zInvalid chunk headerr   z!Negative chunk length not allowed)r4   readlinedecoder<   strip
ValueErrorOSError)r   liner6   es       r   read_chunk_lenzDechunkedInput.read_chunk_lend   s    	9;''))00::Dtzz||R((DD 	9 	9 	9011q8	9!88=>>>s   AA 
A0A++A0buf	bytearrayc                   d}| j         su|t          |          k     ra| j        dk    r|                                 | _        | j        dk    rd| _         | j        dk    rt	          t          |          | j                  }||z   t          |          k    r_| j                            t          |          |z
            ||d <   | xj        t          |          |z
  z  c_        t          |          }n7| j                            |          ||||z   <   | xj        |z  c_        ||z  }| j        dk    r,| j                                        }|dvrt          d          | j         s|t          |          k     a|S )Nr   T)   
   
   z!Missing chunk terminating newline)	r5   lenr6   rG   minr4   readr@   rD   )r   rH   rP   n
terminators        r   readintozDechunkedInput.readinton   sv   * "	GCyA~~ !//11	yA~~ "
y1}} C$),,
 !8c#hh&&!%!1!1#c((T/!B!BCJIISD0IIs88DD+/;+;+;A+>+>Ctax(IINIIAIDyA~~ "[1133
%<<<!"EFFFE * "	GCH r   N)r0   r1   r   r2   r   r8   r   r<   )rH   rI   r   r<   )r   r   r    __doc__r7   r;   rG   rS   r!   r   r   r/   r/   Y   sj        BB   
      & & & & & &r   r/   c                  *    e Zd ZU dZded<   ed*d            Zd+dZd,d
Zd, fdZ		 d-d.dZ
d/ fdZd*dZd0dZe                    d g  ed           edd          D                       Zde ed          <   d1d2d"Zd3d%Zd3d&Zd4d)Z xZS )5WSGIRequestHandlerz3A request handler that implements WSGI dispatching.BaseWSGIServerserverr   r   c                    | j         j        S N)rZ   _server_versionr:   s    r   server_versionz!WSGIRequestHandler.server_version   s    {**r   r+   c                   t          | j                  }| j        j        dnd}| j        sd| _        n(t          | j        t                    r| j        df| _        |j        s|j        rd|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 ]g\  }}d|v r
|                                                    dd          }|                    dd          }|dvrd | }||v r||          d!| }|||<   h|                    d"d                                                                          d#k    rd$|d%<   t?          |d	                   |d	<   |j        r|j        r
|j        |d&<   	 | j                             d$'          }|tC          j"        |          |d(<   n6# tF          $ r | j        $                    d)d*           Y ntJ          $ r Y nw xY w|S )+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_,HTTP_TRANSFER_ENCODINGchunkedTzwsgi.input_terminated	HTTP_HOST)binary_formSSL_CLIENT_CERTerrorz&Cannot fetch SSL peer certificate info)&r
   pathrZ   ssl_contextclient_address
isinstancer   schemenetlocr	   r0   sysstderrmultithreadmultiprocess
connectionr^   commandr   queryaddress_stringport_integerserver_addressrequest_versionheadersitemsupperreplacegetrB   lowerr/   getpeercertsslDER_cert_to_PEM_certrC   logAttributeError)r   request_url
url_scheme	path_infoenvironkeyvalue	peer_certs           r   make_environzWSGIRequestHandler.make_environ   s   ty))#{6>VVG
" 	;"0D+S11 	;#'#6":D
 ! 	)k&8 	)BK.B0@BBII#(II&&	$
F$
z$
 $*$
 3:	$

  7$
  !9$
 U$
 t$
 t2$
 dl$
 2$
 -i88$
 01BCC$
 /	::$
" +DI66#$
$ 4..00%$
& 4,,..'$
(  ;5a8t{9!<==#3-$
 $
 $
2 ,,,.. 
	! 
	!JCczz))++%%c3//CMM&"--E<<<#cmm'>>&s|55e55E GCLL;;/44::<<BBDD	QQ/3G+,$27<3H$I$IGL!  	6+"4 	6#.#5GK 	 333EEI$-0-Ei-P-P)* 	O 	O 	OKOOG%MNNNNN 	 	 	D	 s   4K %K5)	K54K5r2   c                2   	
  j                             dd                                                                          dk    r j                            d                                            x _        d d d 
d dd 
fd
dfd		d 	fd}	  | j        j	                   d S # t          t          j        f$ r!}                     |           Y d }~d S d }~wt          $ r} j        j        r 
	rd _        	 
d d  |t#                                 n# t          $ r Y nw xY wddlm}  ||                                          } j                            dd|            Y d }~d S d }~ww xY w)NExpectrg   z100-continues   HTTP/1.1 100 Continue

Fdatabytesr   r2   c                (   
J d            

J d            
		                      d d          \  }}n# t          $ r d}}Y nw xY wt          |          }                    ||           t	                      }	D ]B\  }}                    ||           |                    |                                           Cd|v sBd         dk    s6d|cxk    rdk     s)n |d	v s#j        d
k    rd                    dd                               dd           	                                 t          | t                    s
J d            | rrhj                            t          t          |                     dd                                                     j                            d           j                            |            rj                            d           j                                         d S )Nzwrite() before start_responser   rg   zcontent-lengthre   HEADd      >   0     HTTP/1.1TzTransfer-Encodingrx   
Connectionclosezapplications must write bytes   rL   )splitrC   r<   send_responsesetsend_headeraddr   protocol_versionend_headersr   r   wfilewritehexrN   encodeflush)r   code_strmsgcodeheader_keysr   r   chunk_responser   headers_sentheaders_setr   status_sent
status_sets          r   r   z*WSGIRequestHandler.run_wsgi.<locals>.write   s[   ))+J)))**,K***"(*4$/$5$5dA$>$>MHcc! 4 4 4$/cHHH48}}""4---!ee". 1 1JC$$S%000OOCIIKK0000 )K77"#34>>4----#----:---;;%)N$$%8)DDD   w777  """dE**KK,KKKK .! .J$$ST^^ABB%7%>%>%@%@AAAJ$$W---
  &&&! .J$$W---Js   < AAc                    |r/	 r!|d                              |d                   	 d }n# d }w xY wrt          d          | |S )Nr   r   zHeaders already set)with_tracebackAssertionError)statusr   exc_infor   r   r   r   s      r   start_responsez3WSGIRequestHandler.run_wsgi.<locals>.start_response5  sw     <$# F&qk88!EEEF  $HHtHOOOO <$%:;;;J!KLs   #, 0appr*   c                $    | 
          }	 |D ]} |           s d           r	j                             d           t          j                    }|                    	j        t          j                   d}d}|                    d          rV	j        	                    d          }|t          |          z  }|dz  }|r|dk    s|d	k    rn|                    d          V|                                 t          |d
          r|                                 d S d S # t          j                    }|                    	j        t          j                   d}d}|                    d          rV	j        	                    d          }|t          |          z  }|dz  }|r|dk    s|d	k    rn|                    d          V|                                 t          |d
          r|                                 w w xY w)Nr   s   0

r   g{Gz?)timeouti r   l    d(	 i  r   )r   r   	selectorsDefaultSelectorregisterr   
EVENT_READselectr0   rP   rN   r   hasattr)r   application_iterr   selector
total_sizetotal_readsr   r   r   r   r   r   s         r   executez,WSGIRequestHandler.run_wsgi.<locals>.executeC  s]   "s7N;;#-,    DE$KKKK# E#JJJ! 3J$$\222 %466!!$/93GHHH
 oodo33 	:??:66D#d))+J1$K   :#?#?;QUCUCU oodo33 	    +W55 -$**,,,,,- -) %466!!$/93GHHH
 oodo33 	:??:66D#d))+J1$K   :#?#?;QUCUCU oodo33 	    +W55 -$**,,,,-s   9D, ,C#HTr   )DebugTracebackr|   zError on request:
)r   r   r   r2   r\   )r   r*   r   r2   )r   r   r   rB   r   r   r   r   rZ   r   ConnectionErrorsocketr   connection_dropped	Exceptionpassthrough_errorsclose_connectionr   debug.tbtoolsr   render_traceback_textr   )r   r   rF   r   r   r   r   r   r   r   r   r   r   s   `    @@@@@@@@r   run_wsgizWSGIRequestHandler.run_wsgi   s   <Hb))//117799^KKJ=>>>!%!2!2!4!44w!%
48"&59$7	 7	 7	 7	 7	 7	 7	 7	 7	 7	 7	 7	r	 	 	 	 	 	 	 	 	%	- %	- %	- %	- %	- %	- %	- %	- %	- %	- %	-N	BGDKO$$$$$0 	0 	0 	0##Aw///////// 	B 	B 	B{- &>&(,% &!%J"&K+--....    655555 .##99;;CKOOG%@3%@%@AAAAAAAAA)	BsI   -C FC66FFD:9F:
EFEAFFc                H   	 t                                                       dS # t          t          j        f$ r }|                     |           Y d}~dS d}~wt          $ r>}| j        j        &t          |          r| 
                    d|           n Y d}~dS d}~ww xY w)z/Handles a request ignoring dropped connections.NzSSL error occurred: %s)superhandler   r   r   r   r   rZ   r~   is_ssl_error	log_error)r   rF   	__class__s     r   r   zWSGIRequestHandler.handle  s    	GGNN0 	' 	' 	'##A&&&&&&&&& 	 	 	{&2|A27;;;; <;;;;;	s     % B!AB!#3BB!Nr|   BaseExceptionr   WSGIEnvironment | Nonec                    dS )z`Called if the connection was closed by the client.  By default
        nothing happens.
        Nr!   )r   r|   r   s      r   r   z%WSGIRequestHandler.connection_dropped  s      r   r   r   c                t    |                     d          r| j        S t          t                      |          S )Ndo_)
startswithr   getattrr   )r   r   r   s     r   r   zWSGIRequestHandler.__getattr__  s5    ??5!! 	!=  uww%%%r   c                j    t          | dd           r| j        d         S | j        sdS | j        d         S )Nr   rl   rb   r   )r   r   r   r:   s    r   r   z!WSGIRequestHandler.address_string  sA    4D)) 	/<.." 	9"1%%r   r<   c                    | j         d         S )Nr   )r   r:   s    r   r   zWSGIRequestHandler.port_integer  s    "1%%r   c                    i | ]	}|d |d
S )z\x02xr!   ).0cs     r   
<dictcomp>zWSGIRequestHandler.<dictcomp>  s"    FFFaM!MMMFFFr             z\\\rr   r   	int | strsizec                H   	 t          | j                  }| j         d| d| j         }n# t          $ r
 | j        }Y nw xY w|                    | j                  }t          |          }|d         dk    rt          |d          }n|dk    rnz|dk    rt          |d          }nc|d         dk    rt          |d	          }nF|d
k    rt          |d          }n/|d         dk    rt          |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   r}   r   r   r   requestline	translate_control_char_tabler   _ansi_styler   )r   r   r   r}   r   s        r   log_requestzWSGIRequestHandler.log_request  sM   	#di((D\AADAA4+?AACC 	# 	# 	#"CCC	#
 mmD4554yy7c>>c6**CCU]]U]]c6**CC!W^^c7++CCU]]c8,,CC!W^^c6511CCc6955CsD$77777s   (+ ??formatargsc                $     | j         d|g|R   d S )Nr|   r   r   r  r  s      r   r   zWSGIRequestHandler.log_error  s$    &(4((((((r   c                $     | j         d|g|R   d S )Nr
  r  r  s      r   log_messagezWSGIRequestHandler.log_message  s$    '$''''''r   typemessagec           	     |    t          ||                                  d|                                  d| dg|R   d S )Nz - - [z] 
)r   r   log_date_time_stringr   r  r  r  s       r   r   zWSGIRequestHandler.log  sd    ""$$VVD,E,E,G,GVV7VVV	
 	
 	
 	
 	
 	
 	
r   )r   r   )r   r+   r   r2   r\   )r|   r   r   r   r   r2   r   rU   )rr   rr   )r   r   r   r   r   r2   )r  r   r  r   r   r2   r  r   r  r   r  r   r   r2   )r   r   r    rV   __annotations__propertyr^   r   r   r   r   r   r   r   r   	maketransranger  ordr  r   r  r   __classcell__r   s   @r   rX   rX      s        ==+ + + X+O O O ObQB QB QB QBf
 
 
 
 
 
 GK    & & & & & && & & && & & & --FF#EUU4[[#E55t3D3D#EFFF  &+D		"8 8 8 8 8:) ) ) )( ( ( (
 
 
 
 
 
 
 
r   rX   r   r   stylesr   c                V    t           s| S ddddddd}|D ]}d||          d	|  } |  d
S )Nr      r   !   #   $   )r   r  r  r  r	  r  z[mz[0m)_log_add_style)r   r&  codesstyles       r   r  r    sj       E  / /.e..u..r   cn
str | None2tuple[Certificate, RSAPrivateKeyWithSerialization]c           	        	 ddl m} ddlm} ddlm} ddlm} ddlm	} n# t          $ r t          d          d w xY w |            }|                    dd	|
          }| d} |                    |                    |j        d          |                    |j        |           g          } |            }|                                                    |                              |                              |                                                              |                                                              t1          j        t4          j                                                t1          j        t4          j                  t;          d          z                                 |                    |j         g          d                              |!                    |"                    |           |"                    d|            g          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*.)%cryptographyr4  cryptography.hazmat.backendsr5  cryptography.hazmat.primitivesr6  )cryptography.hazmat.primitives.asymmetricr7  cryptography.x509.oidr8  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)
r0  r4  r5  r6  r7  r8  r;  pkeysubjectcerts
             r   generate_adhoc_ssl_pairr`    s_   	%%%%%%@@@@@@999999AAAAAA1111111   J
 
	
 oG##g $  D
 
ziiw8:MNNw2B77	
 G oG!!	g			W			DOO%%	&	&	t0022	3	3		"&..	/	/	--	s0C0C0CC	D	D	t,,d.B-CDDu	U	U	''b)9)94<<	R		;R;R(STT 
 

 

 
dFMMOOW	-	- 	 :s   ! <	base_pathhosttuple[str, str]c           	        ||}t          |          \  }}ddlm} |  d}|  d}t          |d          5 }|                    |                    |j        j                             ddd           n# 1 swxY w Y   t          |d          5 }|                    |                    |j        j        |j	        j
        |                                                     ddd           n# 1 swxY 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)r0  r   serializationz.crtz.keywbencodingr  encryption_algorithm)r`  rA  rf  openr   public_bytesEncodingPEMprivate_bytesPrivateFormatTraditionalOpenSSLNoEncryption)	ra  rb  r0  r_  r]  rf  	cert_file	pkey_filefs	            r   make_ssl_devcertrv     s   * (B///JD$<<<<<<"""I"""I	i		 ?!	!!-"8"<==>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ?	i		 
!	&/3$2E%2%?%?%A%A   	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 is$   3A77A;>A;AC00C47C4c            	        ddl } ddl}t                      \  }}ddlm} |                                \  }}|                                \  }}|                     t          j        |           |                     t          j        |           t          j	        ||
                    |j        j                             t          j	        ||                    |j        j        |j        j        |                                                     t          j        |           t          j        |           t%          ||          }	|	S )z:Generates an adhoc SSL context for the development server.r   Nre  rh  )atexittempfiler`  rA  rf  mkstempr   osremover   rl  rm  rn  ro  rp  rq  rr  r   load_ssl_context)
rx  ry  r_  r]  rf  cert_handlers  pkey_handlert  ctxs
             r   generate_adhoc_ssl_contextr  L  s9   MMMOOO(**JD$<<<<<<%--//K%--//K
OOBIy)))
OOBIy)))H[$++M,B,FGGHHHH"+/ .A!.!;!;!=!= 	 	
 	
   H[H[
9i
0
0CJr   rs  rt  protocol
int | Nonec                v    |t           j        }t          j        |          }|                    | |           |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`.
    )r   PROTOCOL_TLS_SERVER
SSLContextload_cert_chain)rs  rt  r  r  s       r   r}  r}  j  s<     *
.
"
"C	9---Jr   r|   Exception | Noner8   c                    | 1t          j        t          t          j                    d                   } t          | t          j                  S )z?Checks if the given error (or the current one) is an SSL error.Nr   )tcastr   r   r   r   r   SSLError)r|   s    r   r   r     s5    }y#,.."344eS\***r   portr<   socket.AddressFamilyc                    |                      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   r  AF_INET)rb  r  s     r   select_address_familyr    sG     y!! ~	44>r   familytuple[str, int] | strc                2   |t           k    r8t          j                            |                     d          d                   S 	 t          j        | ||t
          j        t
          j                  }n# t
          j	        $ r | |fcY S w xY w|d         d         S )zVReturn 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)rb  r  r  ress       r   get_sockaddrr    s    
 wt~~e44Q7888 $ 2F4F
 
 ?   Tzq6!9s   ,A2 2BBc                b   | t           j        k    rdnd}t          j         | t           j                  5 }	 |                    |df           n0# t          $ r# | t           j        k    rdndcY cddd           S w xY w|                                d         cddd           S # 1 swxY w Y   dS )zGet 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connectrD   getsockname)r  rb  ss      r   get_interface_ipr    s#    %+fo$=$=  CSD	vv0	1	1 "Q	GIItUm$$$$ 	G 	G 	G"fo5555;FF	" " " " " " " "	G }}q!" " " " " " " " " " " " " " " " " "s4   B$AB$A;,B$:A;;B$$B(+B(c                  h     e Zd ZdZdZdZeZdZ	 	 	 	 d$d% fdZ	d&dZ
d'd( fdZd) fd"Zd*d#Z xZS )+rY   zuA WSGI server that that handles one request at a time.

    Use :func:`make_server` to create a server instance.
    FTNrb  r   r  r<   r   r*   handlertype[WSGIRequestHandler] | Noner   r8   r~   _TSSLContextArg | Nonefdr  r   r2   c                "   |t           }dt          |          vr| j        s| j        rd|_        || _        || _        || _        || _        t          ||          x| _
        }t          |t          |          |          }	|t          k    rO|Mt          j        t           |	          }	t"          j                            |	          rt#          j        |	           t+                                          |	|d           |	 |                                  |                                  n9# t2          $ r}
|                                  t7          |
j        t:          j                   |
j        t>          j         k    rPt7          d| dt:          j                   t:          j!        dk    r!|d	k    rt7          d
t:          j                   t;          j"        d           Y d }
~
n}d }
~
wtF          $ r |                                   w xY w|                                  tI          j%        ||tH          j&                  | _$        | j$        '                                | _(        |t          k    r| j(        d         | _        |\tS          |tT                    r
tW          | }n|dk    rtY                      }|-                    | j$        d          | _$        || _.        nd | _.        dd l/}d|j0        1                    d           | _2        d 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  zoOn macOS, try disabling the 'AirPlay Receiver' service from System Preferences -> General -> AirDrop & Handoff.r   r)   T)server_sider   z	Werkzeug/werkzeug)3rX   varsr   r   r   rb  r  r   r   r  address_familyr  r<   r  r  r  r   r{  r}   existsunlinkr   r7   server_bindserver_activaterD   server_closeprintstrerrorr   r   errno
EADDRINUSEplatformexitr   r   fromfdr  r  r   r   tupler}  r  wrap_socketr~   importlib.metadatametadataversionr]   )r   rb  r  r   r  r   r~   r  r  r   rF   	importlibr   s               r   r7   zBaseWSGIServer.__init__  s5    ?(G
 T']]22 3 $ 1 3 (2G$		"4/DT4/P/PPn%dCII~FF W$$VC88Nw~~n-- *	.))) 	# 	 	
 	
 	
 :  """$$&&&&    !!###ajsz22227e...! ! ! ! !Z	    |x//DDLLX!$        !!###  !-NF<NOODK"&+"9"9";";DW$$+A.DI"+u-- ;.<''8::%11$+41PPDK6AD#D!!!!S9+=+E+Ej+Q+QSSs   (D. .
H8B-G**#Hr  r  r  r   c                "    t          ||g|R   d S r\   r   r  s       r   r   zBaseWSGIServer.log%  s     T7"T""""""r         ?poll_intervalfloatc                    	 t                                          |           n# t          $ r Y nw xY w|                                  d S # |                                  w xY w)N)r  )r   serve_foreverKeyboardInterruptr  )r   r  r   s     r   r  zBaseWSGIServer.serve_forever(  sx    	 GG!!!>>>>  	 	 	D	 Ds!   "& A 
3A 3A A"requestr   r  c                X    | j         r t                                          ||          S r\   )r   r   handle_error)r   r  r   r   s      r   r  zBaseWSGIServer.handle_error0  s-     " 	ww##G^<<<r   c                j   d}t          |dd          }|g}| j        t          k    r|                    d| j                    n| j        dnd}| j        }| j        dv r|                    d	| j         d
           | j        dk    rd}t          t          j                  }nd}t          t          j	                  }|                    d| d| d| j
                    d|v rd| 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 Nr`   ra   >   ::0.0.0.0z * Running on all addresses ()r  r  z[::1]r  r  []r
  r  )r  r  r  appendrb  r~   r  r   r  r  r  r   join)r   dev_warningmessagesr   display_hostname	localhosts         r   log_startupzBaseWSGIServer.log_startup8  sq   A 	 "+vu==='))OO8TY889999#/7VVWF#yy--- L	 L L LMMM9	)) +I'7'G'G$$ 'I'7'H'H$ S S SI S S	 S STTT&&&#:'7#:#:#: OOVVVV8HVV49VVWWWVTYYx(()))))r   )NFNN)rb  r   r  r<   r   r*   r  r  r   r8   r~   r  r  r  r   r2   r  )r  )r  r  r   r2   )r  r   r   r  r   r2   r  )r   r   r    rV   r   r   LISTEN_QUEUErequest_queue_sizeallow_reuse_addressr7   r   r  r  r  r$  r%  s   @r   rY   rY     s         
 KL% 48#(.2eT eT eT eT eT eT eTN# # # #             = = = = = = *  *  *  *  *  *  *  *r   rY   c                      e Zd ZdZdZdZdS )ThreadedWSGIServerzA WSGI server that handles concurrent requests in separate
    threads.

    Use :func:`make_server` to create a server instance.
    TN)r   r   r    rV   r   daemon_threadsr!   r   r   r  r  [  s$          KNNNr   r  c                  4     e Zd ZdZdZ	 	 	 	 	 dd fdZ xZS )ForkingWSGIServerzA WSGI server that handles concurrent requests in separate forked
    processes.

    Use :func:`make_server` to create a server instance.
    T(   NFrb  r   r  r<   r   r*   	processesr  r  r   r8   r~   r  r  r  r   r2   c	           	         t           st          d          t                                          |||||||           || _        d S )Nz'Your platform does not support forking.)can_forkrC   r   r7   max_children)
r   rb  r  r   r  r  r   r~   r  r   s
            r   r7   zForkingWSGIServer.__init__o  sQ      	HFGGGtS'3E{TVWWW%r   )r  NFNN)rb  r   r  r<   r   r*   r  r<   r  r  r   r8   r~   r  r  r  r   r2   )r   r   r    rV   r   r7   r$  r%  s   @r   r  r  f  sd          L 37#(.2& & & & & & & & & & &r   r  r   r*   threadedr  request_handlerr  r   r~   r  r  c	           
         |r|dk    rt          d          |rt          | ||||||          S |dk    rt          | |||||||          S t          | ||||||          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  )rC   r  r  rY   )	rb  r  r   r  r  r  r   r~   r  s	            r   make_serverr    s    (  QIMMOPPP 
!$_.@+RT
 
 
 	
 1}} 	
 	
 	
 		
 dC*<kb   r   c                 H    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)r{  r   r   r!   r   r   is_running_from_reloaderr    s     :>>-..&88r   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]] | Noner2   c                6   t          |t                    st          d          |rddlm}  |||          }|r-ddlm}  |||          }|j                            |            t                      sd}nt          t          j        d                   }t          | |||
|||||	  	        }|j                            d	           t          |                                          t          j        d<   t                      s2|                                 t%          d
t'          dd                     |rKddlm} 	  ||j        ||||	           |                                 dS # |                                 w xY 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   )r   r<   rE  middleware.shared_datar  debugr  trusted_hostsr  r  r{  r   r  r   set_inheritabler   filenor  r   r  	_reloaderr  r  r  )r  r  r  r  r  r  r  r  r  r   r  r  r  r  r   r~   r  r  r  srvr  s                        r   
run_simpler    s   ` dC   31222 F@@@@@@**;EE 3......))+jIII 	!((222#%% 30122

 
 
C Jt$$$'*3::<<'8'8BJ#$#%% DV[!7BBCCC 000000		!'!1*+    Cs   E, ,F)r   r   r&  r   r   r   r\   )r0  r1  r   r2  )NN)ra  r   rb  r1  r0  r1  r   rc  )r   r(   )rs  r   rt  r1  r  r  r   r(   )r|   r  r   r8   )rb  r   r  r<   r   r  )rb  r   r  r<   r  r  r   r  )r  r  r   r   )Fr   NFNN)rb  r   r  r<   r   r*   r  r8   r  r<   r  r  r   r8   r~   r  r  r  r   rY   rT   )FFTNNr   r  Fr   NNFN)"r  r   r  r<   r  r*   r  r8   r  r8   r  r8   r  r  r  r  r  r<   r   r   r  r8   r  r<   r  r  r  r  r   r8   r~   r  r   r2   )KrV   
__future__r   r  ior{  r   r   socketserverr   typingr  r   rR  r   r   http.serverr   r   urllib.parser	   r
   	_internalr   r   
exceptionsr   urlsr   r   rD  r   r-  r   
__import__r   r  r&   r  r  r   r  OptionalUnionTupler   Literal_TSSLContextArgTYPE_CHECKING_typeshed.wsgir*   r+   -cryptography.hazmat.primitives.asymmetric.rsar,   cryptography.x509r-   	RawIOBaser/   rX   r  r`  rv  r  r}  r   r  r  r  rY   ThreadingMixInr  r  r  r  r  r!   r   r   <module>r'     sk    # " " " " "  				 				          



     # # # # # #             . . . . . . " " " " " "             ! ! ! ! ! !       + + + + + + + + + + + +      JJJJ 	 	 	        )++CCC	 7d??
:    72v ,LL       nGG   GGG *Gagc1:c?&:;QYw=OOP ? .............      .-----; ; ; ; ;R\ ; ; ;|B
 B
 B
 B
 B
/ B
 B
 B
J
   ( . . . . .d ?C)  )  )  )  ) X   > JN    *+ + + + +      "" " " "$e* e* e* e* e*Z e* e* e*P    4n   & & & & &n & & &> 7;$*.* * * * *Z9 9 9 9 *./37;<@$*.!e e e e e e es6   ,A1 1BB!B- -B76B7C& &C0/C0