Your IP : 18.223.238.38


Current Path : /opt/alt/python310/lib64/python3.10/wsgiref/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/wsgiref/__pycache__/simple_server.cpython-310.opt-2.pyc

o

6��f3�@s2	ddlmZmZddlZddlZddlmZddlm	Z	dZ
gd�Zde
Ze	�dej
��dZed	eZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�Zeefdd�Zedkr�edde��'Zej��Zededdedd�ddlZe�d�e��Wd�dS1s�wYdSdS)�)�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�|�dSt�|�w)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close��self�r�</opt/alt/python310/lib64/python3.10/wsgiref/simple_server.pyr s
�zServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrr
sr
c@s2eZdZ	dZdd�Zdd�Zdd�Zdd	�ZdS)
rNcCs	t�|�|��dS�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|jSr��applicationrrrr�get_app?�zWSGIServer.get_appcCs
||_dSrr#)rr$rrr�set_appBs
zWSGIServer.set_app)rrrr$rrr%r'rrrrr*s
rc@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rr
cCsL|jj��}|j|d<|j|d<|j|d<d|jvr$|j�dd�\}}n|jd}}tj	�
|d�|d<||d	<|��}||jd
krF||d<|jd
|d<|j
�d
�dur]|j
��|d<n|j
d
|d<|j
�d�}|rp||d<|j
��D].\}}|�dd���}|��}||vr�qud||vr�|d|d|7<qu||d|<qu|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_stderrpr&zWSGIRequestHandler.get_stderrcCs�	|j�d�|_t|j�dkrd|_d|_d|_|�d�dS|��s%dSt	|j|j
|��|��dd�}||_
|�|j���dS)Niiri�F)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�q|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|�}|�|�|Sr)r')r9�portZappZserver_classZ
handler_classr,rrrr	�s
r	�__main__ri@zServing HTTP onrQrz...zhttp://localhost:8000/xyz?abc)Zhttp.serverrrr=Zurllib.parser2Zwsgiref.handlersr�platformrrD�__all__r/�versionr�sys_versionrr
rrrr	rZhttpdZsocketZgetsocknameZsarIZ
webbrowser�openZhandle_requestrrrr�<module>s4C
�	


"��

?>