FAQ

Jonadab the Unsightly One jonadab at bright.net
Mon Sep 4 11:00:49 CEST 2000


pehr anderson <pehr at pehr.net> wrote:

> Ho Ho! 
> 
> It's easy as pie, 
> 
> CGI works by calling shell scripts,
> which can tell the shell what program
> to use in their execution.
> 
> #!/usr/bin/python
> 
> should be the first line of your program.

(Substituting the correct directory for your system, of course.)

Also note that besides just the HTML you need to print out
an HTTP header first.  At minimum, "Content-type: text/html"
on one line and then a blank line before the start of the
HTML document itself.  For simple purposes that's enough.
You could look up how to do more complicated stuff (like
redirection) by doing a web search for "HTTP headers".
Mostly the Content-type is really the only absolutely
necessary header.

The other things you should know about CGI?

1.  If your form uses the GET method, then Apache pust 
    the info from the form is in the environment variable 
    QUERY_STRING

2.  If your form uses the POST method, then Apache sends
    the info from the form on standard input instead.

That's pretty much it.  If you already know HTML, 
then CGI is really quite easy.  

- jonadab



More information about the Python-list mailing list