summaryrefslogtreecommitdiffhomepage
path: root/test/python
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2020-05-28 18:13:06 +0300
committerAndrei Belov <defan@nginx.com>2020-05-28 18:13:06 +0300
commit733c14e991d6b2d5bdae5202ae9f090d022bc956 (patch)
tree120562db5d30e5f4f51d001397f765f5cebab999 /test/python
parent6a8d4571d7fc89a951b4da80c39a93fcaa634406 (diff)
parent9d8e476c4e3695019b0a1fe3696d3411a8393de6 (diff)
downloadunit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.gz
unit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.bz2
Merged with the default branch.
Diffstat (limited to 'test/python')
-rw-r--r--test/python/ns_inspect/wsgi.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/python/ns_inspect/wsgi.py b/test/python/ns_inspect/wsgi.py
new file mode 100644
index 00000000..fa1222e4
--- /dev/null
+++ b/test/python/ns_inspect/wsgi.py
@@ -0,0 +1,31 @@
+import json
+import os
+
+try:
+ # Python 3
+ from urllib.parse import parse_qs
+except ImportError:
+ # Python 2
+ from urlparse import parse_qs
+
+
+def application(environ, start_response):
+ ret = {
+ 'FileExists': False,
+ }
+
+ d = parse_qs(environ['QUERY_STRING'])
+
+ ret['FileExists'] = os.path.exists(d.get('path')[0])
+
+ out = json.dumps(ret)
+
+ start_response(
+ '200',
+ [
+ ('Content-Type', 'application/json'),
+ ('Content-Length', str(len(out))),
+ ],
+ )
+
+ return out.encode('utf-8')