Files @ b68d19ad38a3
Branch filter:

Location: majic-ansible-roles/roles/wsgi_website/tests/data/python/paste/testapp.py

branko
MAR-33: Added initial scaffolding for wsgi_website tests:

- Added Molecule configuration file.
- Implemented test playbook that sets-up three separate instances of WSGI
website in order to test all variations of parameters.
- Added name for the set_fact task.
- Fixed linting errors related to mode that lacks leading zero.
- Added skip_ansible_lint tag for command that creates the Python virtual
environment.
- Added missing become keyword wherever become_user is specified.
- Fixed invalid parameter name for specifying if HTTPS should be enforced or
not.
- Added small initial sample WSGI apps that get deployed.
- Added static/media sample files.
- Added TLS material.
- Added initial dummy test file.
import os

from flask import Flask
app = Flask(__name__)


@app.route('/')
def index():

    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=os.environ.get("HTTP_ACCEPT_ENCODING", "HTTP accept encoding not set"))

    return output