HTTP server

Simon Forman rogue_pedro at
Sat Jun 24 17:25:32 CEST 2006

placid wrote:
> Hi all,
> Ive been reading about creating a HTTP server like the one pydoc
> creates (and studying pydoc source code). What i want to know, is it
> possible to create server that creates a webpage with hyperlinks that
> communicate back to the HTTP server, where each link accessed tells the
> server to execute some arbitrary command on local machine its running
> on?
> Cheers

Yes.   It is possible.

Ok, seriously,  I don't know how pydoc does it, but when I need a
quick-and-dirty http server [written in python] I use something like

from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

HTTPServer(('', 8000), SimpleHTTPRequestHandler).serve_forever()

For what you're asking about you'd probably want to use the
CGIHTTPRequestHandler from the CGIHTTPServer module instead.  Check out

Then you'd just write one or more cgi scripts (they can be in python
IIRC) to run the commands you want.


More information about the Python-list mailing list