import os VARIABLES = [ 'REMOTE_ADDR', 'SERVER_ADDR', 'HTTPS', 'REQUEST_SCHEME', 'HTTP_HOST', 'SERVER_NAME', 'SCRIPT_NAME', 'QUERY_STRING', ] def print_headers_if_needed(): if not os.environ['SCRIPT_NAME'].endswith('.php'): print('Content-Type: text/html;charset=UTF-8') print() def print_environment(): print('') for key, value in sorted(os.environ.items()): print(''' '''.format(key, value)) print('
{}{}
') def print_variables(): print('') for v in VARIABLES: print(''' '''.format(v, os.environ[v])) print('
{}{}
')