Network Python Tutorial

import BaseHTTPServer, cgi
import os
class httpServHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
     if self.path.find('?') != -1:
         self.path, self.query_string = self.path.split('?', 1)
     else:
         self.query_string = ''
     self.send_response(200)
     self.send_header('Content-type','text/html')
     self.end_headers()
     self.globals = dict(cgi.parse_qsl(self.query_string))
     sys.stdout = self.wfile
     self.wfile.write("

Handle Get

")
     self.wfile.write("

  • Executing %s" % (self.path))
         self.wfile.write("
  • With Globals%s
    " % (self.globals))
         execfile(self.path, self.globals)
    os.chdir('/myTest')
    serv = BaseHTTPServer.HTTPServer(servAddr, httpServHandler)
    serv.serve_forever()