simple web-server

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 28 10:30:20 EDT 2008


En Fri, 28 Mar 2008 08:53:15 -0300, Pavol Murin <palomurin at gmail.com>  
escribió:

> could you point me to a very simple (single file is best) web-server?
> I want to serve a few web-forms and run some shell scripts when the
> forms are submitted. I might add Ajax later (this is not a
> requirement, if it only supports forms it's OK).

Ajax is mostly a client thing, any server would work.

>  I would like to provide a web-page for customization of an
> application - it should run some shell commands as the user clicks
> around in the page and at the end write a configuration file. I had a
> look at the python wiki (http://wiki.python.org/moin/WebProgramming),
> where various web servers and frameworks are listed. The frameworks
> seem to heavy for such a simple task and BaseHTTPServer just seems to
> be too light.

How many requests/minute you expect to handle? From your description, not  
many, I think. So even CGI would be OK, and I'd choose the easiest server  
to configure and setup.
TinyWeb www.ritlabs.com is the smallest web server I know of (Windows  
only, unfortunately), and almost setup-free. Ensure that .py scripts are  
executable, place them in a cgi-bin subdirectory, start tiny.exe and  
you're done.

> So I took a look at the web-servers listed:
>  httpy had the last release 1,5 years ago, Medusa more than 5 years,
> Twisted seems to be able to do a lot, so probably not the simple thing
> I'm looking for. CherryPy looks promising, however it is still 89
> files (including some that can be removed)

Don't make the release dates fool you. The HTTP specs haven't changed in  
years, once you have a functional server, there is no need to keep  
changing it.

>  If CGIHTTPServer is a good answer, could you point me to a good
> (nontrivial) example?

Running CGIHTTPServer takes 3 or 5 lines of code, and that's all to it.  
You don't have to touch the server itself. You write cgi scripts and put  
them somewhere so the server can find and execute them when requested;  
that's all.
So you have to look for CGI examples, not server examples :)

-- 
Gabriel Genellina




More information about the Python-list mailing list