Building a Web Application
Now you can use your new knowledge of the DOM to create a simple web application. Let’s build one that allows for the posting and viewing of articles. The articles are submitted and viewed via a web browser, but stored by the web server as XML, which allows the articles to be leveraged into different information systems that process XML. HTML articles, on the other hand, are unusable outside of a web browser.
Preparing the Web Server
In order to run the examples in this chapter, you must
have a web server available that lets you execute CGI scripts. These
examples were designed on Apache, so the CGI scripts contain a
sh-bang line that specified the path to the
Python executable (the #!/usr/bin/python expression at the top of
the file) so that Apache can run them just like any other CGI script.
(Understanding the term "sh-bang” requires a
little bit of knowledge of Unix history. The traditional command-line
environment for Unix was originally implemented using the sh program. The exclamation point was named
the “bang” character because it was always used after words such as
“bang” and “pow” in comic books and cartoons. Since the lines at the
top of scripts that started with #!
were interpreted by the sh
program, they came to be known as sh-bang
lines.)
Ensuring the script’s execution
You must enable the execution of your Python scripts on your web server. On Apache, this means enabling CGI within the web directory, ensuring that the actual CGI scripts ...