[Tutor] cgiserver update

Kirk Bailey idiot1 at netzero.net
Tue Sep 30 00:19:46 EDT 2003


Having the webpages in the same folder as the python executables leads to 
vulnerabilities, and to confusion. It is better to have the server use a 
different folder as 'webroot' so that web pages are served there, and nothing 
else but what SHOULD be accessable on your pc's webserver- so if used on a LAN, 
your server/site can be accessed, but nothing further up the tree is accessable, 
like any executables you might have lying around in 'C:\Python 22', as one can 
feed commands to the interpeter which it would gleefully execute, to your 
sorrow. Therefore, with advice from STeve, I modified the cgi-server to serve 
from a different web 'root' directory and directories under it.

Here is the new and improved server.

#!C:\Python22\pythonw.exe
# COPYRIGHT 2003 Steve Holden, free for personal use.
# Please visit http://www.holdenweb.com/ to learn more!
#
import CGIHTTPServer, BaseHTTPServer, os
os.chdir ('.\web')
httpd=BaseHTTPServer.HTTPServer(('',8080), CGIHTTPServer.CGIHTTPRequestHandler)
httpd.serve_forever()
#

It was that easy. All my webpages on the server are now in 'C:\Python22\web', 
and under it in cgi-bin are the scripts, and under that the wiki pages. under 
~\web is ~\images, where images live.

It's a server.


-- 

-- 

end

Cheers!
         Kirk D Bailey

  +                              think                                +
   http://www.howlermonkey.net  +-----+        http://www.tinylist.org
   http://www.listville.net     | BOX |  http://www.sacredelectron.org
   Thou art free"-ERIS          +-----+     'Got a light?'-Prometheus
  +                              kniht                                +

Fnord.





More information about the Tutor mailing list