<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

Yf                 @   s  d  Z  d d l m Z m Z d d l m Z d d l Z d d l Z d d l	 m
 Z
 d d l m Z d Z d d	 d
 d g Z d e Z e   d e j j   d Z e d e Z Gd d   d e
  Z Gd d   d e  Z Gd d	   d	 e  Z d d
   Z e e d d  Z e d k re d d e  Z e j j   Z e d e d d e d d  d d l Z e j  d  e j!   e j"   d S)a!  BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
    )BaseHTTPRequestHandler
HTTPServer)BufferedWriterN)SimpleHandler)python_implementationz0.2
WSGIServerWSGIRequestHandlerdemo_appmake_serverzWSGIServer// c               @   s"   e  Z d  Z e Z d d   Z d S)ServerHandlerc             C   sB   z- |  j  j |  j j d d  d |  j  Wd  t j |   Xd  S)Nr      r   )request_handlerZlog_requestZstatussplitZ
bytes_sentr   close)self r   :/opt/alt/python35/lib64/python3.5/wsgiref/simple_server.pyr   !   s    	$zServerHandler.closeN)__name__
__module____qualname__software_versionZserver_softwarer   r   r   r   r   r      s   r   c               @   sL   e  Z d  Z d Z d Z d d   Z d d   Z d d   Z d	 d
   Z d S)r   z7BaseHTTPServer that implements the Python WSGI protocolNc             C   s   t  j |   |  j   d S)z.Override server_bind to store the server name.N)r   server_bindsetup_environ)r   r   r   r   r   1   s    zWSGIServer.server_bindc             C   sY   i  } |  _  |  j | d <d | d <t |  j  | d <d | d <d | d <d | d <d  S)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT REMOTE_HOSTCONTENT_LENGTHZSCRIPT_NAME)base_environZserver_namestrZserver_port)r   envr   r   r   r   6   s    


zWSGIServer.setup_environc             C   s   |  j  S)N)application)r   r   r   r   get_app@   s    zWSGIServer.get_appc             C   s   | |  _  d  S)N)r!   )r   r!   r   r   r   set_appC   s    zWSGIServer.set_app)	r   r   r   __doc__r!   r   r   r"   r#   r   r   r   r   r   +   s   
c               @   s>   e  Z d  Z d e Z d d   Z d d   Z d d   Z d S)	r   zWSGIServer/c             C   s  |  j  j j   } |  j | d <|  j | d <|  j | d <d |  j k rf |  j j d d  \ } } n |  j d } } t j	 j
 | d  | d <| | d	 <|  j   } | |  j d
 k r | | d <|  j d
 | d <|  j j d  d  k r|  j j   | d <n |  j d | d <|  j j d  } | r4| | d <x |  j j   D]v \ } } | j d d  j   } | j   } | | k rqDd | | k r| d | d | 7<qD| | d | <qDW| S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD?r   r   z
iso-8859-1Z	PATH_INFOZQUERY_STRINGr   r   ZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr   -_ZHTTP_,)serverr   copyrequest_versionserver_versioncommandpathr   urllibparseZunquoteZaddress_stringZclient_addressZheadersgetZget_content_typeitemsreplaceupperstrip)r   r    r.   ZqueryhostZlengthkvr   r   r   get_environL   s8    


 zWSGIRequestHandler.get_environc             C   s   t  j S)N)sysstderr)r   r   r   r   
get_stderrq   s    zWSGIRequestHandler.get_stderrc             C   s   |  j  j d  |  _ t |  j  d k rV d |  _ d |  _ d |  _ |  j d  d S|  j   sf d St	 |  j
  } zG t |  j  | |  j   |  j    } |  | _ | j |  j j    Wd | j   Xd S)zHandle a single HTTP requesti  i   r   i  N)ZrfilereadlineZraw_requestlinelenZrequestliner+   r-   Z
send_errorZparse_requestr   Zwfiler   r<   r9   r   Zrunr)   r"   detach)r   stdoutZhandlerr   r   r   handlet   s     			!	zWSGIRequestHandler.handleN)r   r   r   __version__r,   r9   r<   rA   r   r   r   r   r   H   s   
%c             C   s   d d l  m } |   } t d d | t d |  t |  j    } x0 | D]( \ } } t | d t |  d | qO W| d d
 g  | j   j d	  g S)Nr   )StringIOzHello world!file=z200 OKContent-Typetext/plain; charset=utf-8zutf-8)rF   rG   )iorC   printsortedr2   reprgetvalueencode)environZstart_responserC   r@   hr7   r8   r   r   r   r	      s    	 c             C   s&   | |  | f |  } | j  |  | S)zACreate a new WSGI server listening on `host` and `port` for `app`)r#   )r6   portZappZserver_classZhandler_classr)   r   r   r   r
      s    __main__r   i@  zServing HTTP onrP   r   z...zhttp://localhost:8000/xyz?abc)#r$   Zhttp.serverr   r   rH   r   r:   Zurllib.parser/   Zwsgiref.handlersr   platformr   rB   __all__r,   versionr   sys_versionr   r   r   r   r	   r
   r   ZhttpdZsocketZgetsocknameZsarI   Z
webbrowseropenZhandle_requestZserver_closer   r   r   r   <module>   s0   
H
