summaryrefslogtreecommitdiff
path: root/paste/deploy/paster_templates/paste_deploy/+package+/sampleapp.py_tmpl
blob: 5514cfc51ba024a2f27bcc982933f5c6c3a3ae59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cgi

from paste.deploy.config import CONFIG


def application(environ, start_response):
    # Note that usually you wouldn't be writing a pure WSGI
    # application, you might be using some framework or
    # environment.  But as an example...
    start_response('200 OK', [('Content-type', 'text/html')])
    greeting = CONFIG['greeting']
    content = [
        b'<html><head><title>%s</title></head>\n' % greeting.encode('utf-8'),
        b'<body><h1>%s!</h1>\n' % greeting.encode('utf-8'),
        b'<table border=1>\n',
        ]
    items = environ.items()
    items = sorted(items)
    for key, value in items:
        content.append(b'<tr><td>%s</td><td>%s</td></tr>\n'
                       % (key.encode('utf-8'), cgi.escape(repr(value)).encode('utf-8')))
    content.append(b'</table></body></html>')
    return content