Running a Python script when a page is loaded

Michael Geary Mike at DeleteThis.Geary.com
Thu Aug 28 14:01:49 EDT 2003


Andrew Chalk wrote:
> I am developing a CGI app, When the user loads my page I want to
> populate an HTML 'select' box (drop down menu) with items from
> a database. What is the best way to get my Python procedure that
> does this called when the page is loaded?

Normally a CGI app generates the entire page, so you'd already be running
Python code and would just call your function at the right place. Or is
there more to the question that I missed?

If you're running Apache, you can use mod_rewrite to get rid of all the
cgi-bin/scriptname?querystring cruft. For example, at my Geary Central site:

http://www.geary.com/

All of the pages including the home page are generated by Python scripts
(the MoinMoin wiki software), but the URLs look like ordinary static URLs
because mod_rewrite translates them.

-Mike






More information about the Python-list mailing list