ok

Mini Shell

Direktori : /lib64/python3.6/wsgiref/__pycache__/
Upload File :
Current File : //lib64/python3.6/wsgiref/__pycache__/simple_server.cpython-36.opt-2.pyc

3


 \�
@sddlmZmZddlZddlZddlmZddlm	Z	dZ
dddd	gZd
e
Ze	�dej
j�dZedeZGd
d�de�ZGdd�de�ZGdd�de�Zdd�Zeefdd	�Zedk�redde��BZejj�Zededdedd�ddlZejd�ej�WdQRXdS)�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_serverzWSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlercCs4z"|jj|jjdd�d|j�Wdtj|�XdS)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close)�self�r�-/usr/lib64/python3.6/wsgiref/simple_server.pyr szServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrrsrc@s0eZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
rNcCstj|�|j�dS)N)r�server_bind�
setup_environ)rrrrr0s
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)�application)rrrr�get_app?szWSGIServer.get_appcCs
||_dS)N)r )rr rrr�set_appBszWSGIServer.set_app)rrrr rrr!r"rrrrr*s

c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rzWSGIServer/cCsT|jjj�}|j|d<|j|d<|j|d<d|jkrH|jjdd�\}}n|jd}}tj	j
|d�|d<||d	<|j�}||jd
kr�||d<|jd
|d<|j
jd
�dkr�|j
j�|d<n|j
d
|d<|j
jd�}|r�||d<xn|j
j�D]`\}}|jdd�j�}|j�}||k�rq�d||k�r@|d|d|7<q�||d|<q�W|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?r
rz
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)rrr,Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjS)N)�sys�stderr)rrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs||jjd�|_t|j�dkr<d|_d|_d|_|jd�dS|j�sHdSt	|j|j
|j�|j��}||_
|j|jj��dS)Niiri�)Zrfile�readlineZraw_requestline�lenZrequestliner)r+Z
send_errorZ
parse_requestrZwfiler:r7rZrunr'r!)rZhandlerrrr�handless
zWSGIRequestHandler.handleN)rrr�__version__r*r7r:r=rrrrrGs%cCsvddlm}|�}td|d�t|d�t|j��}x$|D]\}}t|dt|�|d�q:W|dd
g�|j�jd	�gS)Nr)�StringIOzHello world!)�file�=z200 OK�Content-Type�text/plain; charset=utf-8zutf-8)rBrC)�ior?�print�sortedr0�repr�getvalue�encode)�environZstart_responser?�stdout�hr5r6rrrr�s
cCs|||f|�}|j|�|S)N)r")r4�portZappZserver_classZ
handler_classr'rrrr	�s
�__main__ri@zServing HTTP onrMr
z...zhttp://localhost:8000/xyz?abc)Zhttp.serverrrr8Zurllib.parser-Zwsgiref.handlersr�platformrr>�__all__r*�versionr�sys_versionrrrrrr	rZhttpdZsocketZgetsocknameZsarEZ
webbrowser�openZhandle_requestrrrr�<module>
s*B





Zerion Mini Shell 1.0