Files
@ eee778bc2d7c
Branch filter:
Location: majic-ansible-roles/roles/wsgi_website/tests/data/python/paste/testapp.py - annotation
eee778bc2d7c
1007 B
text/x-python
MAR-128: Upgraded tests for ROLE_NAME role:
- Switch to new Molecule configuration.
- Updated set-up playbook to use become: yes.
- Moved some preparatory steps outside of the main playbook (eases
idempotence tests).
- Updated tests to reference the yml inventory file.
- Updated tests to use new fixture (host instead of individual ones).
- Switched to extracting hostname instead of hard-coding it in a
couple of tests.
- Renamed hosts instances to include Debian version in their
hostnames.
- Fixed some linting issues.
- Switch to new Molecule configuration.
- Updated set-up playbook to use become: yes.
- Moved some preparatory steps outside of the main playbook (eases
idempotence tests).
- Updated tests to reference the yml inventory file.
- Updated tests to use new fixture (host instead of individual ones).
- Switched to extracting hostname instead of hard-coding it in a
couple of tests.
- Renamed hosts instances to include Debian version in their
hostnames.
- Fixed some linting issues.
b68d19ad38a3 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 998aab91d6b4 998aab91d6b4 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 b68d19ad38a3 b68d19ad38a3 b68d19ad38a3 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 b68d19ad38a3 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 b68d19ad38a3 b68d19ad38a3 | import os
import flask
from flask import Flask
app = Flask(__name__, static_url_path='/keep-default-static-out-of-way')
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
template = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{host}</title>
</head>
<body>
<p>This is the WSGI application at {host}.</p>
<p>Requested URL was: {scheme}://{host}{script}{path}
<p>MY_ENV_VAR: {my_env_var}</p>
<p>Accept-Encoding: {accept_encoding}</p>
</body>
</html>
"""
environ = flask.request.environ
parameters = {}
parameters['host'] = environ['HTTP_HOST']
parameters['scheme'] = environ['wsgi.url_scheme']
parameters['script'] = environ['SCRIPT_NAME']
parameters['path'] = environ['PATH_INFO']
parameters['my_env_var'] = os.environ.get('MY_ENV_VAR', None)
parameters['accept_encoding'] = environ.get('HTTP_ACCEPT_ENCODING')
output = template.format(**parameters)
return output
|