[Tutor] Web Server

Ryan silas428 at gmail.com
Mon Feb 18 19:57:06 CET 2008


I copied a webserver from one O'Reilly's books, but it only works under
windows. Can anyone tell me what to change to get it to work under
linux? Here is the code:

webdir = '.'
port = 80

import os, sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler

if len(sys.argv) > 1: webdir = sys.argv[1]
if len(sys.argv) > 2: port = int(sys.argv[2])
print 'webdir "%s", port %s' % (webdir, port)

if sys.platform[:3] == 'win':
    CGIHTTPRequestHandler.have_popen2 = False
    CGIHTTPRequestHandler.have_popen3 = False
    sys.path.append('cgi-bin')

os.chdir(webdir)
srvaddr = ("", port)
srvobj = HTTPServer(srvaddr, CGIHTTPRequestHandler)
srvobj.serve_forever()





More information about the Tutor mailing list