test
This commit is contained in:
parent
29a88fc652
commit
6ada877b7f
5 changed files with 100 additions and 0 deletions
17
test/debug.php
Executable file
17
test/debug.php
Executable file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
echo('<h1>PHP</h1>');
|
||||
|
||||
echo('<h2>getenv()</h2>');
|
||||
echo('<table>');
|
||||
foreach (getenv() as $k => $v)
|
||||
echo("<tr><td>$k</td><td>$v</td></tr>");
|
||||
echo('</table>');
|
||||
|
||||
echo(getcwd());
|
||||
|
||||
echo('<hr />');
|
||||
|
||||
require(dirname(__FILE__).'/web.php');
|
||||
|
||||
?>
|
14
test/debug.py
Executable file
14
test/debug.py
Executable file
|
@ -0,0 +1,14 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
import web
|
||||
|
||||
|
||||
web.print_headers_if_needed()
|
||||
|
||||
print('<h1>Python</h1>')
|
||||
|
||||
print('<h2>os.environ</h2>')
|
||||
web.print_environment()
|
||||
|
||||
print('<h2>variables</h2>')
|
||||
web.print_variables()
|
15
test/index.cgi
Executable file
15
test/index.cgi
Executable file
|
@ -0,0 +1,15 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from waitress import serve
|
||||
|
||||
|
||||
def app():
|
||||
import web
|
||||
web.print_headers_if_needed()
|
||||
counter += 1
|
||||
print('Counter: {}'.format(counter))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
counter = 0
|
||||
serve(app, unix_socket='/var/run/fcgiwrap.socket')
|
18
test/web.php
Normal file
18
test/web.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
foreach (array(
|
||||
'REMOTE_ADDR',
|
||||
'SERVER_ADDR',
|
||||
'HTTPS',
|
||||
'REQUEST_SCHEME',
|
||||
'HTTP_HOST',
|
||||
'SERVER_NAME',
|
||||
'SCRIPT_NAME',
|
||||
'QUERY_STRING',
|
||||
) as $variable)
|
||||
putenv("$variable=".getenv($variable));
|
||||
|
||||
system(dirname(getenv('SCRIPT_FILENAME')).'/'.
|
||||
basename(getenv('SCRIPT_FILENAME'),'.php').'.py');
|
||||
|
||||
?>
|
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…
Reference in a new issue