Files @ a5916602bdc9
Branch filter:

Location: majic-ansible-roles/testsite/playbooks/roles/wsgihello/files/hello.wsgi

branko
MAR-192: Updated test site instructions/deployment for Debian 12 Bookworm:

- Default to recommending Debian 12 Bookworm.
- Update the demo WSGI application for Python 3 use.
#!/usr/bin/env python

import os

def application(environ, start_response):
    status = '200 OK'

    template = """<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>{title}</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
    <p>I am website {title}</p>
    <p>Accept-Encoding header was set to {acceptencoding}</p>
  </body>
</html>
"""
    output = template.format(title=os.environ.get("WEBSITE_NAME", "that nobody set a name for :("),
                             acceptencoding=environ.get("HTTP_ACCEPT_ENCODING"))

    response_headers = [('Content-type', 'text/html'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output.encode('utf-8')]