Implementing the DISTAL application
Now that we have the data, we can start to implement the DISTAL application itself. To keep things simple, we will use CGI scripts to implement the user interface.
Tip
What is a CGI Script?
While the details of writing CGI scripts are beyond the scope of this book, the basic concept is to print the raw HTML output to stdout
and to process the incoming CGI parameters from the browser using the built-in cgi
module.
To run a Python program as a CGI script on Mac OS X or Linux, you have to do two things: first, you have to add a "shebang" line to the start of the script, like this:
#!/usr/bin/python
The exact path you use will depend on where you have Python installed on your computer. The second thing you need to do is make your script executable, like this:
chmod +x selectCountry.py
On MS Windows computers, the file extension (.py
) will automatically cause the CGI scripts to call the Python interpreter, so you shouldn't need to do either of these things.
For more...