O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

cgi

The cgi module is used to implement CGI scripts in web applications. CGI scripts are programs executed by a web server when it wants to process user input submitted through an HTML form such as the following:

<FORM ACTION=' /cgi-bin/foo.cgi' METHOD= 'GET' >
Your name : <INPUT type= 'Text'  name= 'name'  size= '30' >
Your email address: <INPUT type= 'Text'  name= 'email'  size= '30' >
<INPUT type= 'Submit'  name= 'submit-button'  value= 'Subscribe' >
</FORM>

When the form is submitted, the web server executes the CGI program foo.cgi. CGI programs receive input from two sources: sys.stdin and environment variables set by the server. The following list details common environment variables set by web servers:

VariableDescription
AUTH_TYPEAuthentication ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required