Verktyg Server
Examples
Basic
from verktyg_server import make_socket, make_server
def application(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
return [
("%s: %r\n" % (key, value)).encode('utf-8')
for key, value in environ.items()
]
server = make_server(make_socket('localhost', 8080), application)
server.run_forever()
Basic HTTPS
from verktyg_server import make_socket, make_server, load_ssl_context
def application(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
return [
("%s: %r\n" % (key, value)).encode('utf-8')
for key, value in environ.items()
]
ssl_context = ssl.load_ssl_context(
'/path/to/certificate.pem', '/path/to/key.pem'
)
sock = make_socket('localhost', 8080, ssl_context=ssl_context)
server = make_server(sock, application)
server.run_forever()
Bugs
Please post any problems or feature requests using the issue tracker