#!/usr/bin/python
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET( self ):
self .send_response( 200 )
self .send_header( ‘Content-type‘ , ‘text/html‘ )
self .send_header( ‘Uri‘ , self .path)
self .end_headers()
self .wfile.write( "hi multi threading test!\n" )
class ThreadingHttpServer(ThreadingMixIn, HTTPServer):
pass
PORT_NUM = 8080
serverAddress = ("", PORT_NUM)
server = ThreadingHttpServer(serverAddress, myHandler)
print ‘Started httpserver on port ‘ , PORT_NUM
server.serve_forever()
|