test
This commit is contained in:
parent
29a88fc652
commit
6ada877b7f
5 changed files with 100 additions and 0 deletions
36
test/web.py
Normal file
36
test/web.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
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('<table>')
|
||||
for key, value in sorted(os.environ.items()):
|
||||
print('''
|
||||
<tr><td>{}</td><td>{}</td></tr>
|
||||
'''.format(key, value))
|
||||
print('</table>')
|
||||
|
||||
|
||||
def print_variables():
|
||||
print('<table>')
|
||||
for v in VARIABLES:
|
||||
print('''
|
||||
<tr><td>{}</td><td>{}</td></tr>
|
||||
'''.format(v, os.environ[v]))
|
||||
print('</table>')
|
Loading…
Add table
Add a link
Reference in a new issue