From 4141e70da97d924969b48fcd198e5996d615e75d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Sep 2008 18:45:09 +0200 Subject: Properly call WSGI request handler when requests come in. --- source4/web_server/swat/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/web_server/swat') diff --git a/source4/web_server/swat/__init__.py b/source4/web_server/swat/__init__.py index e0d85dbe2c..580097186c 100644 --- a/source4/web_server/swat/__init__.py +++ b/source4/web_server/swat/__init__.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # Unix SMB/CIFS implementation. # Copyright © Jelmer Vernooij 2008 @@ -19,7 +20,7 @@ # along with this program. If not, see . # -def SWAT(environ, start_response): +def __call__(environ, start_response): status = '200 OK' response_headers = [('Content-type','text/plain')] start_response(status, response_headers) -- cgit From ef8d9f8a756936578dc770a0ec275e57aa3ee51b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Sep 2008 20:00:44 +0200 Subject: Make standard SWAT script print received headers. --- source4/web_server/swat/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/web_server/swat') diff --git a/source4/web_server/swat/__init__.py b/source4/web_server/swat/__init__.py index 580097186c..8229d15a3c 100644 --- a/source4/web_server/swat/__init__.py +++ b/source4/web_server/swat/__init__.py @@ -22,7 +22,13 @@ def __call__(environ, start_response): status = '200 OK' - response_headers = [('Content-type','text/plain')] + response_headers = [('Content-type','text/html')] start_response(status, response_headers) - return ['Hello world!\n'] + yield '\n' + + for key, value in environ.items(): + if isinstance(value, str): + yield '\t\n' % (key, value) + + yield '
%s%s
\n' -- cgit From bbfce1b43d183cdccbe6f9a189098091f9d4a251 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Sep 2008 20:06:18 +0200 Subject: Allow SWAT to be run outside of smbd. --- source4/web_server/swat/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/web_server/swat') diff --git a/source4/web_server/swat/__init__.py b/source4/web_server/swat/__init__.py index 8229d15a3c..d434bb260b 100644 --- a/source4/web_server/swat/__init__.py +++ b/source4/web_server/swat/__init__.py @@ -32,3 +32,8 @@ def __call__(environ, start_response): yield '\n' +if __name__ == '__main__': + from wsgiref import simple_server + httpd = simple_server.make_server('localhost', 8090, __call__) + print "Serving HTTP on port 8090..." + httpd.serve_forever() -- cgit