[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1






When we visit this alternative page with a browser, we get the interface shown in
Figure 15-15.


Figure 15-15. Form page created by tutor5b.html


Now, before you go blind trying to detect the differences in this and the prior HTML
file, I should note that the HTML differences that produce this page are much less
important for this book than the fact that the action fields in these two pages’ forms
reference identical URLs. Pressing this version’s Submit button triggers the exact same
and totally unchanged Python CGI script again, tutor5.py (Example 15-12).


That is, scripts are completely independent of both the transmission mode (URL query
parameters of form fields) and the layout of the user interface used to send them in-
formation. Changes in the response page require changing the script, of course, because
the HTML of the reply page is still embedded in the CGI script. But we can change the
input page’s HTML as much as we like without affecting the server-side Python code.
Figure 15-16 shows the response page produced by the script this time around.


1168 | Chapter 15: Server-Side Scripting

Free download pdf