cinap_lenrekadd hg and python4bb9e2215 years agoHistory
1071 lines · 34.2 KB · Python
RawDownload
    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("&", "&amp;") # Must be done first!    s = s.replace("<", "&lt;")    s = s.replace(">", "&gt;")    if quote:        s = s.replace('"', "&quot;")    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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t