[Tutor] Web Server
Ryan
silas428 at gmail.com
Mon Feb 18 20:16:27 CET 2008
Awesome, thanks, I also forgot to check the error messages(had to go to
command line and run it as root)
On Mon, 2008-02-18 at 14:05 -0500, Kent Johnson wrote:
> Ryan wrote:
> > 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?
>
> What happens when you try it? My guess is you get an error opening a
> socket to listen to port 80. Try port 8000.
>
> Kent
>
> > 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()
> >
> >
> >
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
More information about the Tutor
mailing list