Files
PowerToys/PythonHome/Lib/wsgiref/simple_server.pyc

38 lines
5.7 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@scdZddlmZmZddlZddlZddlmZdZdddd gZ d
eZ
d ej j <00>d Z e
d e Zdefd<00><00>YZdefd<00><00>YZdefd<00><00>YZd<00>Zeed<00>Zedkr_edde<00>Zejj<00>ZdGed GdGedGdGHddlZejd<00>ej<00>ej<00>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<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(tBaseHTTPRequestHandlert
HTTPServerN(t SimpleHandlers0.1t
WSGIServertWSGIRequestHandlertdemo_appt make_servers WSGIServer/sPython/it t ServerHandlercBseZeZd<00>ZRS(cCsBz-|jj|jjdd<00>d|j<00>Wdtj|<00>XdS(NRii(trequest_handlert log_requesttstatustsplitt
bytes_sentRtclose(tself((s.\Lib\wsgiref\simple_server.pyRs $(t__name__t
__module__tsoftware_versiontserver_softwareR(((s.\Lib\wsgiref\simple_server.pyRscBs8eZdZdZd<00>Zd<00>Zd<00>Zd<00>ZRS(s7BaseHTTPServer that implements the Python WSGI protocolcCstj|<00>|j<00>dS(s.Override server_bind to store the server name.N(Rt server_bindt setup_environ(R((s.\Lib\wsgiref\simple_server.pyR.s cCsYi}|_|j|d<d|d<t|j<00>|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.\Lib\wsgiref\simple_server.pyR3s  


cCs|jS(N(t application(R((s.\Lib\wsgiref\simple_server.pytget_app=scCs ||_dS(N(R"(RR"((s.\Lib\wsgiref\simple_server.pytset_app@sN( RRt__doc__tNoneR"RRR#R$(((s.\Lib\wsgiref\simple_server.pyR(s  
cBs-eZdeZd<00>Zd<00>Zd<00>ZRS(s WSGIServer/c Cs<>|jjj<00>}|j|d<|j|d<d|jkrY|jjdd<00>\}}n|jd}}tj|<00>|d<||d<|j <00>}||j
dkr<>||d <n|j
d|d
<|j j dkr<>|j j|d <n|j j |d <|j jd <00>}|r||d <nx<>|j j D]<5D>}|jdd<00>\}}|jdd<00>j<00>}|j<00>}||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.\Lib\wsgiref\simple_server.pyt get_environIs8  
     cCstjS(N(tsyststderr(R((s.\Lib\wsgiref\simple_server.pyt
get_stderrnscCsl|jj<00>|_|j<00>s"dSt|j|j|j<00>|j<00><00>}||_|j |j
j <00><00>dS(sHandle a single HTTP requestN( trfiletreadlinetraw_requestlinet parse_requestRtwfileRLRIR trunR3R#(Rthandler((s.\Lib\wsgiref\simple_server.pythandleqs $ (RRt __version__tserver_versionRIRLRT(((s.\Lib\wsgiref\simple_server.pyREs
 % cCs<>ddlm}|<00>}|dIJ|J|j<00>}|j<00>x0|D](\}}||IdIt|<00>IJqDW|ddg<00>|j<00>gS( Ni<4E><69><EFBFBD><EFBFBD>(tStringIOs Hello world!t=s200 OKs Content-Types
text/plain(s Content-Types
text/plain(RWtitemstsorttreprtgetvalue(tenvirontstart_responseRWtstdoutRFRGRH((s.\Lib\wsgiref\simple_server.pyR<00>s 

 cCs&|||f|<00>}|j|<00>|S(sACreate a new WSGI server listening on `host` and `port` for `app`(R$(RDtporttappt server_classt handler_classR3((s.\Lib\wsgiref\simple_server.pyR<00>s t__main__Ri@sServing HTTP onR`is...shttp://localhost:8000/xyz?abc(R%tBaseHTTPServerRRR8RJtwsgiref.handlersRRUt__all__RVtversionR t sys_versionRRRRRRRthttpdtsockett getsocknametsat
webbrowsertopenthandle_requestt server_close(((s.\Lib\wsgiref\simple_server.pyt<module> s*
;