Executing a python script from an HTML link?

Alan Kennedy alanmk at hotmail.com
Tue Sep 23 19:58:50 CEST 2003

[Andrew Chalk]
> I want to run the script on the server. 

Then you will need to figure out how to run the script on the server

If you're not aware of how to do this, then it's probably best for you
to read up on CGI, which is way of getting web servers to execute
scripts (in any language) when the scripts URL is requested.

> The problem is that I don't
> have an html page as an HREF. Viz:
> <tr><A HREF="Fred.htm">Fred</A>
> What replaces Fred.htm to invoke a server-side script?

Whatever is the URL of your script on your server. Examples include


Your python script should then generate (i.e. print out) an HTML page
when it is run (actually it can generate anything, images included,
but HTML is a good place to start). The server takes the output of
your script and sends it to the requesting browser. The browser has no
way of knowing that the HTML did not come from a static file.

You can read about Python and CGI here:-


There are other "linkage mechanisms" by which you can cause the
execution of scripts on a server, e.g. mod_python, but none is
conceptually as simple as CGI. Also, CGI tends to be more portable
between different server software, and is almost always supported by
hosting providers.


alan kennedy
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan

More information about the Python-list mailing list