Files @ 1bb9f7ac1072
Branch filter:

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

branko
MAR-112: Added alternate SMTP port:

- Updated mail_server role to deploy firewall rules that include redirection
from TCP port 27 to TCP port 25.
- Updated documentation to include references to the additional port.
- Updated tests to cover the new functionality.
#!/usr/bin/env python

import os
import ipcalc

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>
    <p>Available IP range for subnet {subnet} is from {subnet_first} to {subnet_last}</p>
  </body>
</html>
"""
    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]