diff options
author | Jan-Philip Gehrcke <jgehrcke@googlemail.com> | 2016-10-14 16:38:13 +0200 |
---|---|---|
committer | Jan-Philip Gehrcke <jgehrcke@googlemail.com> | 2016-10-14 16:38:13 +0200 |
commit | 8909e7df1b335b40c0d4578cc55f9deaf52f325e (patch) | |
tree | e9e10c0453e94602670c6786984da0f707075090 /example | |
parent | ccb842d20b9a4a2334706a180a69a39136f37f08 (diff) | |
download | pysaml2-8909e7df1b335b40c0d4578cc55f9deaf52f325e.tar.gz |
example/sp-wsgi/sp.py: respond with bytes (enhance WSGI compliance)
Diffstat (limited to 'example')
-rwxr-xr-x | example/sp-wsgi/sp.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/example/sp-wsgi/sp.py b/example/sp-wsgi/sp.py index 38a737ee..be1e8e68 100755 --- a/example/sp-wsgi/sp.py +++ b/example/sp-wsgi/sp.py @@ -106,21 +106,21 @@ def handle_static(environ, start_response, path): :return: wsgi response for the static file. """ try: - text = open(path).read() + data = open(path, 'rb').read() if path.endswith(".ico"): - resp = Response(text, headers=[('Content-Type', "image/x-icon")]) + resp = Response(data, headers=[('Content-Type', "image/x-icon")]) elif path.endswith(".html"): - resp = Response(text, headers=[('Content-Type', 'text/html')]) + resp = Response(data, headers=[('Content-Type', 'text/html')]) elif path.endswith(".txt"): - resp = Response(text, headers=[('Content-Type', 'text/plain')]) + resp = Response(data, headers=[('Content-Type', 'text/plain')]) elif path.endswith(".css"): - resp = Response(text, headers=[('Content-Type', 'text/css')]) + resp = Response(data, headers=[('Content-Type', 'text/css')]) elif path.endswith(".js"): - resp = Response(text, headers=[('Content-Type', 'text/javascript')]) + resp = Response(data, headers=[('Content-Type', 'text/javascript')]) elif path.endswith(".png"): - resp = Response(text, headers=[('Content-Type', 'image/png')]) + resp = Response(data, headers=[('Content-Type', 'image/png')]) else: - resp = Response(text) + resp = Response(data) except IOError: resp = NotFound() return resp(environ, start_response) |