Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

others on your Raspberry Pi system seeing the log files that are generated:


Click here to view code image


cgitb.enable(display=0, logdir='/tmp')

Figure 22.6 shows what the webpage shows after you add this line to the script2206.cgi
program.


FIGURE 22.6 The cgitb.enable() output on the webpage.

The log file that is generated contains the HTML code of the error webpage that would have been
displayed in the browser.


Processing Forms


Web applications allow you to easily collect and process data from site visitors. Web forms provide
an excellent way to interact with your program users to retrieve dynamic data for processing or
storage in databases.


The Python CGI environment provides an easy way for your Python scripts to retrieve and use form
data in your web applications. The follow sections walk through how you use it.


Creating Web Forms


The HTML standard provides elements you can use to create forms. Your site visitors can then fill
out these forms to submit data to your web applications. Table 22.2 lists the HTML form elements.

Free download pdf