print sys.argv print def print_environ_usage(): """Dump a list of environment variables used by CGI as HTML.""" print """<H3>These environment variables could have been set:</H3><UL><LI>AUTH_TYPE<LI>CONTENT_LENGTH<LI>CONTENT_TYPE<LI>DATE_GMT<LI>DATE_LOCAL<LI>DOCUMENT_NAME<LI>DOCUMENT_ROOT<LI>DOCUMENT_URI<LI>GATEWAY_INTERFACE<LI>LAST_MODIFIED<LI>PATH<LI>PATH_INFO<LI>PATH_TRANSLATED<LI>QUERY_STRING<LI>REMOTE_ADDR<LI>REMOTE_HOST<LI>REMOTE_IDENT<LI>REMOTE_USER<LI>REQUEST_METHOD<LI>SCRIPT_NAME<LI>SERVER_NAME<LI>SERVER_PORT<LI>SERVER_PROTOCOL<LI>SERVER_ROOT<LI>SERVER_SOFTWARE</UL>In addition, HTTP headers sent by the server may be passed in theenvironment as well. Here are some common variable names:<UL><LI>HTTP_ACCEPT<LI>HTTP_CONNECTION<LI>HTTP_HOST<LI>HTTP_PRAGMA<LI>HTTP_REFERER<LI>HTTP_USER_AGENT</UL>""" # Utilities# ========= def escape(s, quote=None): '''Replace special characters "&", "<" and ">" to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (") is also translated.''' s = s.replace("&", "&") # Must be done first! s = s.replace("<", "<") s = s.replace(">", ">") if quote: s = s.replace('"', """) return s def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"): import re return re.match(_vb_pattern, s) # Invoke mainline# =============== # Call test() when this file is run as a script (not imported as a module)if __name__ == '__main__': test()Lines 1001–1071 of 1071. Previous lines
print sys.argv print def print_environ_usage(): """Dump a list of environment variables used by CGI as HTML.""" print """ <H3>These environment variables could have been set:</H3> <UL> <LI>AUTH_TYPE <LI>CONTENT_LENGTH <LI>CONTENT_TYPE <LI>DATE_GMT <LI>DATE_LOCAL <LI>DOCUMENT_NAME <LI>DOCUMENT_ROOT <LI>DOCUMENT_URI <LI>GATEWAY_INTERFACE <LI>LAST_MODIFIED <LI>PATH <LI>PATH_INFO <LI>PATH_TRANSLATED <LI>QUERY_STRING <LI>REMOTE_ADDR <LI>REMOTE_HOST <LI>REMOTE_IDENT <LI>REMOTE_USER <LI>REQUEST_METHOD <LI>SCRIPT_NAME <LI>SERVER_NAME <LI>SERVER_PORT <LI>SERVER_PROTOCOL <LI>SERVER_ROOT <LI>SERVER_SOFTWARE </UL> In addition, HTTP headers sent by the server may be passed in the environment as well. Here are some common variable names: <UL> <LI>HTTP_ACCEPT <LI>HTTP_CONNECTION <LI>HTTP_HOST <LI>HTTP_PRAGMA <LI>HTTP_REFERER <LI>HTTP_USER_AGENT </UL> """ # Utilities # ========= def escape(s, quote=None): '''Replace special characters "&", "<" and ">" to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (") is also translated.''' s = s.replace("&", "&") # Must be done first! s = s.replace("<", "<") s = s.replace(">", ">") if quote: s = s.replace('"', """) return s def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"): import re return re.match(_vb_pattern, s) # Invoke mainline # =============== # Call test() when this file is run as a script (not imported as a module) if __name__ == '__main__': test()