The
The web form is just HTML code, and you need to place it in the standard /var/www folder to serve it to web clients:
Click here to view code image
sudo cp script2207.html /var/www sudo chmod +x /var/www/script2207.html
You can then open your browser to view the form by using this URL:
http://localhost/script2207.html
You should see a form like the one in Figure 22.7.
FIGURE 22.7 The basic web form used for the Python script.
Now you’re ready to write the Python script to retrieve and process the form data.
The cgi Module
When the webpage passes the form data back to the Apache web server, it groups the data in key/value pairs. The key is the HTML element name for the form field in the webpage, and the value is the data value that was entered in the form field.
For example, this HTML code associates the key name lname with the value entered into that form field: