Recommendation for a small web framework like Perl's CGI::Application to run as CGI?

Tim Chase python.list at tim.thechases.com
Tue Jan 27 22:52:12 CET 2009


> I need to make a small, relatively low-traffic site that users can
> create accounts on and log into. Scripts must run as cgi (no
> mod_python or FastCGI is available). Can anyone recommend a small and
> simple web framework for Python, maybe similar to Perl's
> CGI::Application?
> 
> Or would it just be better to roll my own?


What are you looking for in your framework?  Python comes with 
its own CGI module[1].  For the most basic of sites, this works 
nicely.

However, if you want to be able to easily slide into a bigger 
environment, I've been pleased with WebStack[2] for my 
lightweight needs.  It makes light work of transitioning from CGI 
to other stacks such as mod_python, Twisted, WSGI, etc.

Backed with a simple sqlite DB, and some simple HTML/Python 
templating, just using dict-expansion:

   # template.html contains content like
   # <p><b>field1</b> = %(field1)s</p>
   template = file('template.html').read()
   :
   :
   params = {
     "field1": "value1",
     "field2": "value2",
     }
   :
   :
   return template % params

Just set up the values in the params-dict, and use it to display 
your template.

-tkc

[1]
http://docs.python.org/library/cgi.html

[2]
http://www.boddie.org.uk/python/WebStack.html





More information about the Python-list mailing list