forked from artekw/viess2mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.py
31 lines (24 loc) · 856 Bytes
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env python
# Python's bundled WSGI server
from wsgiref.simple_server import make_server
def application (environ, start_response):
# Sorting and stringifying the environment key, value pairs
response_body = [
'%s: %s' % (key, value) for key, value in sorted(environ.items())
]
response_body = '\n'.join(response_body)
status = '200 OK'
response_headers = [
('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))
]
start_response(status, response_headers)
return [response_body]
# Instantiate the server
httpd = make_server (
'localhost', # The host name
8051, # A port number where to wait for the request
application # The application object name, in this case a function
)
# Wait for a single request, serve it and quit
httpd.handle_request()