File: dump_wsgi.py

package info (click to toggle)
python-falcon 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 33,608; javascript: 92; sh: 50; makefile: 50
file content (29 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def application(environ, start_response):
    # wsgi_errors = environ['wsgi.errors']

    start_response('200 OK', [('Content-Type', 'text/plain')])

    body = '\n{\n'
    for key, value in environ.items():
        # if isinstance(value, str):
        body += '    "{0}": "{1}",\n'.format(key, value)

    body += '}\n\n'

    if not isinstance(body, bytes):
        body = body.encode('utf-8')

    return [body]


app = application


if __name__ == '__main__':
    from wsgiref.simple_server import make_server

    server = make_server('localhost', 8000, application)

    print('Listening on localhost:8000...')

    server.serve_forever()