B
    d                 @   s  d 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 yddlZW n( ek
r   G dd dZe ZY nX dZejdkr.yed W n ek
r,   dZY nX eedZ e rFej!Z!nG dd dZ!y
ej"Z#W n e$k
rx   dZ#Y nX dZ%ej&ej'dej(e)ej&e) f df  Z*ej+rddl,Z-ddl.m/Z/ ddl.m0Z0 ddl1m2Z2 ddl3m4Z4 G dd  d ej5Z6G d!d" d"eZ7e)e)e)d#d$d%Z8dOej&e) ej(d& d'd(d)Z9dPe)ej&e) ej&e) ej(e)e)f d*d+d,Z:dd-d.d/Z;dQe)ej&e) ej&e< dd0d1d2Z=dRej&e> e?d3d4d5Z@e)e<ejAd6d7d8ZBe)e<ejAej'ej(e)e<f e)f d9d:d;ZCejAe)d<d=d>ZDG d?d@ d@eZEG dAdB dBejFeEZGG dCdD dDe!eEZHdSe)e<dEe?e<ej&ejIe7  e?ej&e* ej&e< eEdF
dGdHZJe?d-dIdJZKdTe)e<dEe?e?e?ej&ejLe)  ej&ejLe)  e<e)e?e<ej&ejIe7  ej&ejMe)ej'e)ej(e)e)f f f  e?ej&e* ddLdMdNZNdS )Ua  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
    N)datetime)	timedelta)timezone)BaseHTTPRequestHandler)
HTTPServer   )_log)_wsgi_encoding_dance)InternalServerError)
uri_to_iri)	url_parse)url_unquotec               @   s   e Zd ZeejdddZdS )	_SslDummy)namereturnc             C   s   t dd S )NzUSSL is unavailable because this Python runtime was not compiled with SSL/TLS support.)RuntimeError)selfr    r   B/var/www/html/venv/lib/python3.7/site-packages/werkzeug/serving.py__getattr__'   s    z_SslDummy.__getattr__N)__name__
__module____qualname__strtAnyr   r   r   r   r   r   &   s   r   TntZcoloramaFforkc               @   s   e Zd ZdS )ForkingMixInN)r   r   r   r   r   r   r   r   =   s   r      zssl.SSLContextzte.Literal['adhoc'])WSGIApplication)WSGIEnvironment)RSAPrivateKeyWithSerialization)Certificatec               @   sR   e Zd ZdZeje ddddZedddZ	e
dd	d
Zee
dddZdS )DechunkedInputz8An input stream that handles Transfer-Encoding 'chunked'N)rfiler   c             C   s   || _ d| _d| _d S )NFr   )_rfile_done_len)r   r%   r   r   r   __init__Y   s    zDechunkedInput.__init__)r   c             C   s   dS )NTr   )r   r   r   r   readable^   s    zDechunkedInput.readablec          
   C   sd   y"| j  d}t| d}W n, tk
rN } ztd|W d d }~X Y nX |dk r`td|S )Nlatin1   zInvalid chunk headerr   z!Negative chunk length not allowed)r&   readlinedecodeintstrip
ValueErrorOSError)r   liner(   er   r   r   read_chunk_lena   s    zDechunkedInput.read_chunk_len)bufr   c             C   s   d}x| j s|t|k r| jdkr,|  | _| jdkr<d| _ | jdkrtt|| j}|| t|kr| jt|| ||d < |  jt|| 8  _t|}n.| j||||| < |  j|8  _||7 }| jdkr| j }|dkrtdqW |S )Nr   T)   
s   
   z!Missing chunk terminating newline)	r'   lenr(   r5   minr&   readr-   r2   )r   r6   r;   n
terminatorr   r   r   readintok   s(    






zDechunkedInput.readinto)r   r   r   __doc__r   IObytesr)   boolr*   r/   r5   	bytearrayr>   r   r   r   r   r$   V   s
   
r$   c                   s  e Zd ZU dZded< eedddZdddd	Zd
dddZ	d
d fddZ
d%eejd d
dddZeejd fddZedddZedddZd&ejeef ejeef d
dddZeejd
dddZeejd
dd d!Zeeejd
d"d#d$Z  ZS )'WSGIRequestHandlerz3A request handler that implements WSGI dispatching.BaseWSGIServerserver)r   c             C   s   ddl m} d| S )Nr   )__version__z	Werkzeug/) rG   )r   rG   r   r   r   server_version   s    z!WSGIRequestHandler.server_versionr!   c             C   s  t | j}| jjd krdnd}| js,d| _nt| jtrD| jdf| _|jsd|jrdd|j |j }n|j}t	|}d|| j
tj| jj| jjd| j| j| jdt|t|jt| jt| j|  |  | jjd t| jjd	 | jd
}xj| j D ]\\}}| dd}|dd}|dkrFd| }||krF||  d| }|||< qW |dd  dkrd|d< t|d |d< |jr|jr|j|d< y*| jj dd}|d k	rt!"||d< W n8 t#k
r   | j$dd Y n t%k
r    Y nX |S )Nhttphttps)z<local>r   r   /)r   r   FrH   r   )zwsgi.versionzwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocesszwsgi.run_oncezwerkzeug.socketSERVER_SOFTWAREREQUEST_METHODZSCRIPT_NAMEZ	PATH_INFOZQUERY_STRINGZREQUEST_URIZRAW_URIREMOTE_ADDRZREMOTE_PORTZSERVER_NAMEZSERVER_PORTZSERVER_PROTOCOL-_z
)ZCONTENT_TYPEZCONTENT_LENGTHZHTTP_,ZHTTP_TRANSFER_ENCODINGchunkedTzwsgi.input_terminatedz
wsgi.inputZ	HTTP_HOST)binary_formZSSL_CLIENT_CERTerrorz&Cannot fetch SSL peer certificate info)&r   pathrF   ssl_contextclient_address
isinstancer   schemenetlocr   r%   sysstderrmultithreadmultiprocess
connectionrI   commandr	   queryaddress_stringport_integerserver_addressrequest_versionheadersitemsupperreplacegetr0   lowerr$   getpeercertsslDER_cert_to_PEM_certr1   logAttributeError)r   request_url
url_schemeZ	path_infoenvironkeyvalueZ	peer_certr   r   r   make_environ   sh    







zWSGIRequestHandler.make_environNc                s  j dd  dkr&jd   _d d d d d td d fdddfd	d
	dd d fdd}y|j	j
 W n ttjfk
r } z| W d d }~X Y n tk
r } zj	jr d k	r rd_y d kr$d d |t  W n tk
rF   Y nX ddlm} || }j	dd|  W d d }~X Y nX d S )NZExpectrH   z100-continues   HTTP/1.1 100 Continue

F)datar   c                s  d k	st dd k	s t dd kryd d\}}W n tk
rd   d }}Y nX t|}|| t }x*D ]"\}}|| ||  qW d|ksd dksd|  krdk sn |d	ksj	d
krd dd dd 
  t| ts t d| rv rXjtt| dd    jd j|   rvjd j  d S )Nzwrite() before start_responser   rH   zcontent-lengthrN   HEADd      >   0     zHTTP/1.1TzTransfer-EncodingrS   
Connectionclosezapplications must write bytes   s   
)AssertionErrorsplitr1   r/   Zsend_responsesetZsend_headeraddrl   protocol_versionZend_headersrY   rA   wfilewritehexr9   encodeflush)rx   Zcode_strmsgcodeheader_keysru   rv   )chunk_responsert   headers_sentheaders_setr   status_sent
status_setr   r   r      sB    


 z*WSGIRequestHandler.run_wsgi.<locals>.writec                s@   |r(z r|d  |d W d d }X nr4td| |S )Nr   r   zHeaders already set)with_tracebackr   )statusrg   exc_info)r   r   r   r   r   r   start_response1  s    z3WSGIRequestHandler.run_wsgi.<locals>.start_responser    )appr   c          	      sZ   | }z6x|D ]}| qW s.d  r>j d W d t|drT|  X d S )N    s   0

r   )r   r   hasattrr   )r   Zapplication_iterrx   )r   rt   r   r   r   r   r   r   execute?  s    


z,WSGIRequestHandler.run_wsgi.<locals>.executeTr   )DebugTracebackrU   zError on request:
)N)rg   rk   rl   r0   r   r   rw   rt   rA   rF   r   ConnectionErrorsockettimeoutconnection_dropped	Exceptionpassthrough_errorsZclose_connectionr
   Zdebug.tbtoolsr   Zrender_traceback_textrp   )r   r   r4   r   r   r   )	r   rt   r   r   r   r   r   r   r   r   run_wsgi   s<     9
zWSGIRequestHandler.run_wsgic          
      s   yt    W nv ttjfk
r@ } z| | W dd}~X Y nF tk
r } z(| jjdk	rrt	|rr| 
d| n W dd}~X Y nX dS )z/Handles a request ignoring dropped connections.NzSSL error occurred: %s)superhandler   r   r   r   r   rF   rW   is_ssl_error	log_error)r   r4   )	__class__r   r   r   f  s    zWSGIRequestHandler.handle)rU   rt   r   c             C   s   dS )z`Called if the connection was closed by the client.  By default
        nothing happens.
        Nr   )r   rU   rt   r   r   r   r   r  s    z%WSGIRequestHandler.connection_dropped)r   r   c                s   | dr| jS tt |S )NZdo_)
startswithr   getattrr   )r   r   )r   r   r   r   y  s    
zWSGIRequestHandler.__getattr__c             C   s*   t | dd r| jd S | js dS | jd S )Nrt   rO   z<local>r   )r   rt   rX   )r   r   r   r   rc     s
    
z!WSGIRequestHandler.address_stringc             C   s
   | j d S )Nr   )rX   )r   r   r   r   rd     s    zWSGIRequestHandler.port_integerrP   )r   sizer   c             C   s   y&t | j}| j d| d| j }W n tk
r@   | j}Y nX t|}|d dkrbt|d}np|dkrlnf|dkrt|d}nR|d dkrt|d	}n:|d
krt|d}n&|d dkrt|dd}nt|dd}| dd||| d S )N r   1boldZ200Z304cyan3greenZ404yellow4redmagentainfoz
"%s" %s %s)	r   rV   ra   rf   rq   Zrequestliner   _ansi_stylerp   )r   r   r   rV   r   r   r   r   log_request  s(    
zWSGIRequestHandler.log_request)formatargsr   c             G   s   | j d|f|  d S )NrU   )rp   )r   r   r   r   r   r   r     s    zWSGIRequestHandler.log_errorc             G   s   | j d|f|  d S )Nr   )rp   )r   r   r   r   r   r   log_message  s    zWSGIRequestHandler.log_message)typemessager   r   c             G   s.   t ||   d|   d| df|  d S )Nz - - [z] 
)r   rc   Zlog_date_time_string)r   r   r   r   r   r   r   rp     s    zWSGIRequestHandler.log)N)rP   rP   )r   r   r   r?   __annotations__propertyr   rI   rw   r   r   BaseExceptionr   Optionalr   r   r   rc   r/   rd   Unionr   r   r   rp   __classcell__r   r   )r   r   rD      s"   
Ny	rD   )rv   stylesr   c             G   sF   t s| S ddddddd}x |D ]}d||  d	|  } q W |  d
S )Nr          !   #   $   )r   r   r   r   r   r   z[mz[0m)_log_add_style)rv   r   codesstyler   r   r   r     s    
r   )r#   r"   )cnr   c       
      C   s:  y@ddl m} ddlm} ddlm} ddlm} ddlm	} W n t
k
r^   tdd Y nX | }|jdd	|d
}| d krd} |||jd||j| g}| }| ||| | ttjttjtdd j||j gddj|!|"| gdd#||$ |}	|	|fS )Nr   )x509)NameOID)default_backend)hashes)rsaz<Using ad-hoc certificates requires the cryptography library.i  i   )Zpublic_exponentZkey_sizebackend*zDummy Certificateim  )daysF)critical)%Zcryptographyr   Zcryptography.x509.oidr   Zcryptography.hazmat.backendsr   cryptography.hazmat.primitivesr   Z)cryptography.hazmat.primitives.asymmetricr   ImportError	TypeErrorZgenerate_private_keyNameZNameAttributeZORGANIZATION_NAMEZCOMMON_NAMEZCertificateBuilderZsubject_nameZissuer_nameZ
public_keyZserial_numberZrandom_serial_numberZnot_valid_beforedtnowr   utcZnot_valid_afterr   add_extensionZExtendedKeyUsageZOID_SERVER_AUTHZSubjectAlternativeNameZDNSNamesignSHA256)
r   r   r   r   r   r   r   pkeysubjectcertr   r   r   generate_adhoc_ssl_pair  s<    


r   )	base_pathhostr   r   c       	   	   C   s   |dk	rd| d| }t |d\}}ddlm} |  d}|  d}t|d	}|||jj W dQ R X t|d	(}||j|jj|j	j
| d
 W dQ R X ||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.
    Nz*.z/CN=)r   r   )serializationz.crtz.keywb)encodingr   encryption_algorithm)r   r   r   openr   public_bytesEncodingPEMprivate_bytesPrivateFormatTraditionalOpenSSLNoEncryption)	r   r   r   r   r   r   	cert_file	pkey_filefr   r   r   make_ssl_devcert  s    

r   )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   N)r   )r   r   r   )tempfileatexitr   r   r   mkstempregisterosremover   r   r   r   r   r   r   r   r   load_ssl_context)
r   r   r   r   r   Zcert_handler   Zpkey_handler   ctxr   r   r   generate_adhoc_ssl_context%  s&    



r   )r   r   protocolr   c             C   s(   |dk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)rn   PROTOCOL_TLS_SERVER
SSLContextload_cert_chain)r   r   r  r   r   r   r   r   C  s
    
r   )rU   r   c             C   s(   | dkrt tt d } t| tjS )z?Checks if the given error (or the current one) is an SSL error.Nr   )r   castr   r\   r   rY   rn   SSLError)rU   r   r   r   r   X  s    r   )r   portr   c             C   s.   |  drtjS d| k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)r   r  r   r   r   select_address_family_  s
    
r  )r   r  familyr   c             C   sZ   |t kr| ddd S yt| ||tjtj}W n tjk
rL   | |fS X |d d S )zVReturn a fully qualified socket address that can be passed to
    :func:`socket.bind`.z://r   r      )af_unixr   r   getaddrinfoSOCK_STREAMIPPROTO_TCPgaierror)r   r  r  resr   r   r   get_sockaddri  s    
r  )r  r   c          	   C   sn   | t jkrdnd}t  | t jD}y||df W n" tk
rV   | t jkrRdS dS X | d S Q R X 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::1z	127.0.0.1r   N)r   r	  
SOCK_DGRAMconnectr2   getsockname)r  r   sr   r   r   get_interface_ipy  s    r  c            
       s   e Zd ZdZdZdZeZdZde	e
dejeje  eeje eje
 dd fddZe	e	ejdd	d
dZdedd fddZejejeje	e
f e	f dd fddZddddZ  ZS )rE   zuA WSGI server that that handles one request at a time.

    Use :func:`make_server` to create a server instance.
    FTNr    )r   r  r   handlerr   rW   fdr   c          
      s  |d krt }dt|kr*| js$| jr*d|_|| _|| _|| _|| _t	|| | _
}t|t||}	|tkr|d krtt|	}	tj|	rt|	 t j|	|dd |d krty|   |   W n tk
rR }
 zn|   t|
jtjd |
jtj kr8td| dtjd tj!dkr8|d	kr8td
tjd t"d W d d }
~
X Y n  t#k
rp   |    Y nX n&|   t$%||t$j&| _$| j$' | _(|tkr| j(d | _|d k	rt)|t*rt+| }n|dkrt, }|j-| j$dd| _$|| _.nd | _.d S )Nr   zHTTP/1.1F)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  zZOn macOS, try disabling the 'AirPlay Receiver' service from System Preferences -> Sharing.r   ZadhocT)server_side)/rD   varsr^   r_   r   r   r  r   r   r  address_familyr  r/   r  r   r  r   r   rV   existsunlinkr   r)   server_bindserver_activater2   server_closeprintstrerrorr\   r]   errno
EADDRINUSEplatformexitr   r   fromfdr  r  re   rY   tupler   r   wrap_socketrW   )r   r   r  r   r  r   rW   r  r"  re   r4   )r   r   r   r)     sf    










zBaseWSGIServer.__init__)r   r   r   r   c             G   s   t ||f|  d S )N)r   )r   r   r   r   r   r   r   rp     s    zBaseWSGIServer.log      ?)poll_intervalr   c                s<   z,yt  j|d W n tk
r(   Y nX W d |   X d S )N)r2  )r   serve_foreverKeyboardInterruptr'  )r   r2  )r   r   r   r3    s
    
zBaseWSGIServer.serve_forever)requestrX   r   c                s   | j r t ||S )N)r   r   handle_error)r   r5  rX   )r   r   r   r6    s    zBaseWSGIServer.handle_error)r   c             C   s   d}t |dd}|g}| jtkr4|d| j  n| jdkrBdnd}| j}| jdkr|d	| j d
 | jdkrd}ttj}nd}ttj	}|d| d| d| j
  d|krd| 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 NrJ   rK   >   ::0.0.0.0z * Running on all addresses ()z0.0.0.0z	127.0.0.1z[::1]z://r  []r   r   )r   r"  r  appendr   rW   r  r   r  r	  r  r   join)r   Zdev_warningmessagesrZ   Zdisplay_hostname	localhostr   r   r   log_startup  s&    



zBaseWSGIServer.log_startup)NFNN)r1  )r   r   r   r?   r^   r_   LISTEN_QUEUErequest_queue_sizeallow_reuse_addressr   r/   r   r   TyperD   rB   _TSSLContextArgr)   r   rp   floatr3  r   Tupler6  r@  r   r   r   )r   r   rE     s      (Z	rE   c               @   s   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   r?   r^   daemon_threadsr   r   r   r   rH  /  s   rH  c                   sT   e Zd ZdZdZd
eedeejej	e
  eeje eje dd	 fdd	Z  ZS )ForkingWSGIServerzA WSGI server that handles concurrent requests in separate forked
    processes.

    Use :func:`make_server` to create a server instance.
    T(   NFr    )	r   r  r   	processesr  r   rW   r  r   c	       	   	      s.   t stdt ||||||| || _d S )Nz'Your platform does not support forking.)can_forkr1   r   r)   max_children)	r   r   r  r   rL  r  r   rW   r  )r   r   r   r)   C  s    zForkingWSGIServer.__init__)rK  NFNN)r   r   r   r?   r_   r   r/   r   r   rD  rD   rB   rE  r)   r   r   r   )r   r   rJ  :  s       *rJ  r    )
r   r  r   threadedrL  request_handlerr   rW   r  r   c	       	   
   C   sd   |r|dkrt d|r.t| ||||||dS |dkrNt| |||||||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  )r1   rH  rJ  rE   )	r   r  r   rO  rL  rP  r   rW   r  r   r   r   make_serverU  s"    rQ  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
    ZWERKZEUG_RUN_MAINtrue)r   rt   rk   r   r   r   r   is_running_from_reloader  s    rS  auto)hostnamer  applicationuse_reloaderuse_debugger
use_evalexextra_filesexclude_patternsreloader_intervalreloader_typerO  rL  rP  static_filesr   rW   r   c             C   s   t |tstd|r,ddlm} |||}|rHddlm} |||d}t sTd}nttj	d }t
| |||
|||||d	}|jd	 t| tj	d< t s|  td
tdd |rddlm} z||j||||	d W d|  X n|  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 serve 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)ZevalexNZWERKZEUG_SERVER_FD)r  Tr   zPress CTRL+C to quitr   )run_with_reloader)rZ  r[  intervalr]  )rY   r/   r   Zmiddleware.shared_datar_  debugr`  rS  r   rt   rQ  r   set_inheritabler   filenor@  r   r   Z	_reloaderra  r3  r'  )rU  r  rV  rW  rX  rY  rZ  r[  r\  r]  rO  rL  rP  r^  r   rW   r_  r`  r  Zsrvra  r   r   r   
run_simple  sJ    p

rf  )N)NN)NN)N)Fr   NFNN)FFTNNr   rT  Fr   NNFN)Or?   r*  ior   r   socketserverr\   typingr   r   r   r   r   Zhttp.serverr   r   	_internalr   r	   
exceptionsr
   urlsr   r   r   rn   r   r   r   r   
__import__r   rM  r   r
  r  rq   rA  r   r   rG  r   rE  TYPE_CHECKINGtyping_extensionsteZ_typeshed.wsgir    r!   Z-cryptography.hazmat.primitives.asymmetric.rsar"   Zcryptography.x509r#   	RawIOBaser$   rD   r   r   r   r   r/   r   r   rB   r   AddressFamilyr  r  r  rE   ThreadingMixInrH  rJ  rD  rQ  rS  IterableDictrf  r   r   r   r   <module>   s   



">  &
-*" %     ,#            p