这段时间在学Python,今天开始进入到CGI编程,示例中有个简单CGI Server的例子,代码如下: webserver.py: webdir = "." #html files directory port = 8000 #server port import os, sys from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler if sys.platform[:3] == "win": CGIHTTPRequestHandler.have_popen2 = False CGIHTTPRequestHandler.have_popen3 = False os.chdir(webdir) srvraddr = ("", port) srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler) srvrobj.serve_forever() 页面CGI为cgi101.py: #!/usr/bin/python import cgi form = cgi.FieldStorage() print "Content-type: text/html/n" print "<title>Reply Page</title>" if not form.has_key("username"): print "<h1>Who are you?</h1>" else: print "<h1&