import os, sys
import BaseHTTPServer, cgi
servAddr = ('',8080)
#Define the HTTP handler that overrides do_GET
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()
#Setup Global Environment
self.globals = dict(cgi.parse_qsl(self.query_string))
#Redirect output to browser
sys.stdout = self.wfile
#Execute the script remotely
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()