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 ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.