posted May 10, 2017, 7:06 AM by Samuel Konstantinovich   [ updated May 11, 2017, 8:06 AM ]
CGI - Common Gateway Interface

CGI scripts are run by the web server in response to HTTP requests. 
Often they process data that is submitted through forms or the URL string.

Data is sent to your CGI programs directly (we will see this later) or via the URL string. We will explore the URL string today. 

CGI handles URL and direct data the same way, so you don't have to worry about how the data is sent, or modify your code later!

In your python website you can get the data passed to the website using the cgi module:
import cgi
formdata = cgi.FieldStorage()

now we discuss what you can do with it... NOTES!

make a copy of your book analysis, name it wordcountCGI.py and modify it as follows:
Read in the field storage in this version.
If no book is selected, show war of the worlds.
If a book is selected, show that book.
Make 3 links at the top of your website that link back to the same file, and pick the book you want

<a href="http://www.mysite.com/~bross/wordcountCGI.py?book=war">
  View War of the Worlds


<a href="wordcountCGI.py?book=war">
  View War of the Worlds