tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
X\¬Qc@sYdZddlmZmZddlZddlZddlmZdZdddd    gZ    d
eZ
d ej j ƒd Z e
d e Zdefd„ƒYZdefd„ƒYZdefd„ƒYZd„Zeed„ZedkrUeddeƒZejjƒZdGed GdGedGdGHddlZejdƒejƒndS(s*BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)
 
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.
iÿÿÿÿ(tBaseHTTPRequestHandlert
HTTPServerN(t SimpleHandlers0.1t
WSGIServertWSGIRequestHandlertdemo_appt make_servers WSGIServer/sPython/it t ServerHandlercBseZeZd„ZRS(cCsBz-|jj|jjddƒd|jƒWdtj|ƒXdS(NRii(trequest_handlert log_requesttstatustsplitt
bytes_sentRtclose(tself((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyRs    $(t__name__t
__module__tsoftware_versiontserver_softwareR(((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyRscBs8eZdZdZd„Zd„Zd„Zd„ZRS(s7BaseHTTPServer that implements the Python WSGI protocolcCstj|ƒ|jƒdS(s.Override server_bind to store the server name.N(Rt server_bindt setup_environ(R((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyR.s cCsYi}|_|j|d<d|d<t|jƒ|d<d|d<d|d<d|d<dS(    Nt SERVER_NAMEsCGI/1.1tGATEWAY_INTERFACEt SERVER_PORTtt REMOTE_HOSTtCONTENT_LENGTHt SCRIPT_NAME(t base_environt server_nametstrt server_port(Rtenv((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyR3s  
 
 
cCs|jS(N(t application(R((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pytget_app=scCs ||_dS(N(R"(RR"((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pytset_app@sN(    RRt__doc__tNoneR"RRR#R$(((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyR(s         
   cBs-eZdeZd„Zd„Zd„ZRS(s WSGIServer/c    Cs¿|jjjƒ}|j|d<|j|d<d|jkrY|jjddƒ\}}n|jd}}tj|ƒ|d<||d<|j    ƒ}||j
dkr²||d    <n|j
d|d
<|j j dkrè|j j|d <n|j j |d <|j jd ƒ}|r||d <nx›|j j D]}|jddƒ\}}|jddƒjƒ}|jƒ}||kr~q*nd||kr©|d|cd|7<q*||d|<q*W|S(NtSERVER_PROTOCOLtREQUEST_METHODt?iRt    PATH_INFOt QUERY_STRINGiRt REMOTE_ADDRt CONTENT_TYPEscontent-lengthRt:t-t_tHTTP_t,(tserverRtcopytrequest_versiontcommandtpathR turllibtunquotetaddress_stringtclient_addresstheaderst
typeheaderR&ttypet    getheadertreplacetuppertstrip(    RR!R7tquerythosttlengththtktv((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyt get_environIs8  
     cCstjS(N(tsyststderr(R((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyt
get_stderrnscCsl|jjƒ|_|jƒs"dSt|j|j|jƒ|jƒƒ}||_|j    |j
j ƒƒdS(sHandle a single HTTP requestN( trfiletreadlinetraw_requestlinet parse_requestRtwfileRLRIR    trunR3R#(Rthandler((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pythandleqs $    (RRt __version__tserver_versionRIRLRT(((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyREs
    %    cCsddlm}|ƒ}|dIJ|J|jƒ}|jƒx0|D](\}}||IdIt|ƒIJqDW|ddgƒ|jƒgS(    Niÿÿÿÿ(tStringIOs Hello world!t=s200 OKs Content-Types
text/plain(s Content-Types
text/plain(RWtitemstsorttreprtgetvalue(tenvirontstart_responseRWtstdoutRFRGRH((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyR€s    
 
 cCs&|||f|ƒ}|j|ƒ|S(sACreate a new WSGI server listening on `host` and `port` for `app`(R$(RDtporttappt server_classt handler_classR3((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyRŒs t__main__Ri@sServing HTTP onR`is...shttp://localhost:8000/xyz?abc(R%tBaseHTTPServerRRR8RJtwsgiref.handlersRRUt__all__RVtversionR t sys_versionRRRRRRRthttpdtsockett getsocknametsat
webbrowsertopenthandle_request(((s]/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/wsgiref/simple_server.pyt<module> s(
;