AlkantarClanX12

Your IP : 52.15.37.74


Current Path : /opt/alt/python39/lib64/python3.9/wsgiref/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/wsgiref/__pycache__/simple_server.cpython-39.pyc

a

R�f3�@s2dZddlmZmZddlZddlZddlmZddl	m
Z
dZgd�ZdeZ
e
�d	ej��dZe
d
eZGdd�de�ZGd
d�de�ZGdd�de�Zdd�Zeefdd�Zedk�r.edde��LZej��Zededdedd�ddlZe�d�e��Wd�n1�s$0YdS)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�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2)�
WSGIServer�WSGIRequestHandler�demo_app�make_server�WSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlerc	Cs>z,|j�|j�dd�d|j�Wt�|�nt�|�0dS)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close��self�r�:/opt/alt/python39/lib64/python3.9/wsgiref/simple_server.pyr s
�zServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrr
sr
c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz7BaseHTTPServer that implements the Python WSGI protocolNcCst�|�|��dS)z.Override server_bind to store the server name.N)r�server_bind�
setup_environrrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS�N��applicationrrrr�get_app?szWSGIServer.get_appcCs
||_dSr"r#)rr$rrr�set_appBszWSGIServer.set_app)	rrr�__doc__r$rrr%r&rrrrr*s
rc@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rr
cCsP|jj��}|j|d<|j|d<|j|d<d|jvrH|j�dd�\}}n|jd}}tj	�
|d�|d<||d	<|��}||jd
kr�||d<|jd
|d<|j
�d
�dur�|j
��|d<n|j
d
|d<|j
�d�}|r�||d<|j
��D]`\}}|�dd���}|��}||v�rq�d||v�r>|d|d|7<q�||d|<q�|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?rrz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rr!r1Zquery�hostZlength�k�vrrr�get_environKs6




zWSGIRequestHandler.get_environcCstjSr")�sys�stderrrrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs�|j�d�|_t|j�dkr<d|_d|_d|_|�d�dS|��sHdSt	|j|j
|��|��dd�}||_
|�|j���dS)zHandle a single HTTP requestiiri�NF)Zmultithread)Zrfile�readlineZraw_requestline�lenZrequestliner.r0Z
send_errorZ
parse_requestr
Zwfiler?r<r�runr,r%)rZhandlerrrr�handless
�zWSGIRequestHandler.handleN)rrr�__version__r/r<r?rCrrrrrGs%rcCsrddlm}|�}td|d�t|d�t|���}|D]\}}t|dt|�|d�q8|ddg�|���d�gS)	Nr)�StringIOzHello world!)�file�=z200 OK)zContent-Typeztext/plain; charset=utf-8zutf-8)�iorE�print�sortedr5�repr�getvalue�encode)�environZstart_responserE�stdout�hr:r;rrrr�s
rcCs|||f|�}|�|�|S)zACreate a new WSGI server listening on `host` and `port` for `app`)r&)r9�portZappZserver_classZ
handler_classr,rrrr	�s
r	�__main__ri@zServing HTTP onrQrz...zhttp://localhost:8000/xyz?abc) r'Zhttp.serverrrr=Zurllib.parser2Zwsgiref.handlersr�platformrrD�__all__r/�versionr�sys_versionrr
rrrr	rZhttpdZsocketZgetsocknameZsarIZ
webbrowser�openZhandle_requestrrrr�<module>s.C
�