[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Step 3: Putting It All Together—A New Reply Script There’s one last step on our path to software maintenance nirvana: we must re ...
Syntax""" langhtml = """ %s %s """ def showHello(form): # HTML for one language choice = form[inputkey].value # escape lang name ...
Most of the code changes in this version of the reply script are straightforward. If you test-drive these pages, the only differ ...
just for the language’s code snippet. This wasn’t required in languages2.py ( Exam- ple 15-20) for the known language names in o ...
translated to such escape sequences, and spaces are replaced by + signs. Technically, this convention is known as the applicatio ...
'a < b > c & d "spam"' >>> s = cgi.escape("1<2 <b>hello</b>") &g ...
>>> urllib.parse.quote_plus("C:\stuff\spam.txt") 'C%3A%5Cstuff%5Cspam.txt' >>> x = urllib.parse.quote_plus("a ...
hyperlink tags; the file languages2.py, for instance, prints HTML that includes a URL: <a href="getfile.py?filename=cgi-bin\ ...
escapes. This text appears to parse correctly in Python’s own HTML parser module described earlier (unless the parts in question ...
When these links are clicked, they invoke the simple CGI script in Example 15-25. This script displays the inputs sent from the ...
Having said that, I should add that some examples in this book do not escape & URL separators embedded within HTML simply be ...
print('Content-type: text/html\n') # wrap up in HTML print('Languages') print("Source code: '%s'" % filename) print('') print(cg ...
Displaying Arbitrary Server Files on the Client Almost immediately after writing the languages source code viewer script in the ...
def restricted(filename): for path in privates: if samefile(path, filename): # unify all paths by os.stat return True # else ret ...
viewer, we could replace the hyperlink to the script languages-src.py in language.html, with a URL of this form (I included both ...
From a higher perspective, URLs like these are really direct calls (albeit across the Web) to our Python script, with filename p ...
exactly as if we had done so manually. It shows up at the end of the URL in the response page’s address field, even though we re ...
That makes for a flexible tool, but it’s also potentially dangerous if you are running a server on a remote machine. What if we ...
handler clause, and they display the exception’s message—fetched using Python’s sys.exc_info—to give additional context. Figure ...
Uploading Client Files to the Server The getfile script lets us view server files on the client, but in some sense, it is a gene ...
«
58
59
60
61
62
63
64
65
66
67
»
Free download pdf