[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
>>> cooks['visited'] = time.asctime() >>> cooks['username'] = 'Bob' >>> cooks['username']['path'] = ' ...
cookies = http.cookies.SimpleCookie() # print Set-cookie hdr cookies['user'] = 'Brian' print(cookies) greeting = 'His name shall ...
>>> >>> reply = urllib.urlopen('http://localhost/cgi-bin/cookies.py').read() >>> print(reply) b'<p ...
are ideal for storing more complex cross-session information; a shopping cart applica- tion, for instance, can record items adde ...
not just a single page, and things like memory leaks become much more costly. For more on persistent CGI models, and support in ...
This demo shows how to display a "hello world" message in various programming languages' syntax. To keep this simple, only the o ...
Example 15-18. PP4E\Internet\Web\cgi-bin\languages.py !/usr/bin/python """ show hello world syntax for input language name; note ...
class dummy: # mocked-up input obj def init(self, str): self.value = str import cgi, sys if debugme: form = {inputkey: dummy(sys ...
For example, the << left-shift operator in the C++ entry is translated to <<— a pair of HTML escape codes. B ...
we could achieve similar results with a default argument in showHello, albeit at the cost of introducing a special case in its c ...
C:\...\PP4E\Internet\Web\cgi-bin> python languages.py All Content-type: text/html <TITLE>Languages</TITLE> <H1 ...
Figure 15-23. Response page for “All” languages choice Checking for Missing and Invalid Inputs So far, we’ve been triggering the ...
>>> from urllib.request import urlopen >>> request = 'http://localhost/cgi-bin/languages.py?language=Python' & ...
To test this error case interactively, the pull-down list includes an “Other” name, which produces a similar error page reply. A ...
update the HTML, too). More generally, there are a handful of ways that this program might fail the scrutiny of a rigorous code ...
hellos = { 'Python': r" print('Hello World') ", 'Python2': r" print 'Hello World' ", 'Perl': r' print "Hello World\n"; ', 'Tcl': ...
Next, in Example 15-20, we recode the main page as an executable script and populate the response HTML with values imported from ...
values imported from the common module. It’s otherwise similar to the original HTML file’s code; when we visit this script’s URL ...
Example 15-21. PP4E\Internet\Web\cgi-bin\formMockup.py """ Tools for simulating the result of a cgi.FieldStorage() call; useful ...
C:\...\PP4E\Internet\Web\cgi-bin> python formMockup.py Bob hacker Spam eggs ham 38 Brian Since the mock-up now lives in a mod ...
«
57
58
59
60
61
62
63
64
65
66
»
Free download pdf