comparison wsgi_test.py @ 2:e07789816ca5

adding more python files from lib/python on origen
author Henry Thompson <ht@markup.co.uk>
date Mon, 09 Mar 2020 16:48:09 +0000
parents
children
comparison
equal deleted inserted replaced
1:0a3abe59e364 2:e07789816ca5
1 from wsgiref.simple_server import make_server
2
3 # Every WSGI application must have an application object - a callable
4 # object that accepts two arguments. For that purpose, we're going to
5 # use a function (note that you're not limited to a function, you can
6 # use a class for example). The first argument passed to the function
7 # is a dictionary containing CGI-style envrironment variables and the
8 # second variable is the callable object (see PEP 333).
9 n = 0
10 def hello_world_app(environ, start_response):
11 global n
12 status = '200 OK' # HTTP Status
13 headers = [('Content-type', 'text/plain')] # HTTP Headers
14 start_response(status, headers)
15
16 # The returned object is going to be printed
17 n=n+1
18 return ["Hello World %s"%n]
19
20 httpd = make_server('', 8000, hello_world_app)
21 print "Serving on port 8000..."
22
23 # Serve until process is killed
24 httpd.serve_forever()
25 f