diff --git a/testsite/playbooks/roles/wsgihello2/files/hello.wsgi b/testsite/playbooks/roles/wsgihello2/files/hello.wsgi new file mode 100644 index 0000000000000000000000000000000000000000..68b65298718ed4f7c426eb04ea5d1e7f33fcdf6f --- /dev/null +++ b/testsite/playbooks/roles/wsgihello2/files/hello.wsgi @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import os +import ipcalc + +def application(environ, start_response): + status = '200 OK' + + template = """ + + + + {title} + + +

Hello, world!

+

I am website {title}

+

Accept-Encoding header was set to {acceptencoding}

+

Available IP range for subnet {subnet} is from {subnet_first} to {subnet_last}

+ + +""" + subnet = ipcalc.Network('10.128.128.0/24') + + output = template.format(title=os.environ.get("WEBSITE_NAME", "that nobody set a name for :("), + acceptencoding=environ.get("HTTP_ACCEPT_ENCODING"), + subnet=str(subnet), + subnet_first=subnet.host_first(), + subnet_last=subnet.host_last()) + + response_headers = [('Content-type', 'text/html'), + ('Content-Length', str(len(output)))] + start_response(status, response_headers) + + return [output]