CGI Scripting

CGI Overview

  • Common protocol web servers use to run external programs in response to HTTP requests.
  • Typical uses: forms processing, dynamic content generation

How it works

  • You write some sort of form in your HTML document
     <form method="GET" action="cgi-bin/spam.cgi">
     Your name: <input type="text" name="name" size=30><p>
     Your email: <input type="text" name="email" size=40><p>
     <input type="submit" value="Submit"></form>
  • This gets translated into request with parameters
     GET /cgi-bin/spam.cgi?name=Dave+Beazley&email=beazley%40cs HTTP/1.0
     
  • Web-server (e.g., Apache) launches CGI program and passes parameters
  • That program writes to stdout to produce the web-page.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 97
July 17, 2000, beazley@cs.uchicago.edu
>>>