From: Magnus Hagander Date: Fri, 28 Jun 2019 17:02:56 +0000 (+0200) Subject: Flask responses need to be bytestrings, not real strings X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=64b32771bff52a9cd9e404c7c044b5c1cf5f55f5;p=hamn.git Flask responses need to be bytestrings, not real strings Seems if a string is returned, flask just turns it into an empty response (rather than converting it to utf8 as expected). These are trivial hardcoded strings though, so just use bytestrings. --- diff --git a/redirector/redirector.py b/redirector/redirector.py index 4f8fa9d..6cce162 100755 --- a/redirector/redirector.py +++ b/redirector/redirector.py @@ -53,7 +53,7 @@ def application(environ, start_response): start_response('404 Not Found', [ ('Content-type', 'text/plain'), ]) - return ["Link not found\n"] + return [b"Link not found\n"] # We have a link, return a redirect to it start_response('301 Moved Permanently', [ @@ -62,9 +62,9 @@ def application(environ, start_response): ('X-Planet', str(id)) ]) return [ - "\n\npostgr.es\n\n\n", - "moved here\n" % r[0][0], - "\n\n" + b"\n\npostgr.es\n\n\n", + b"moved here\n" % r[0][0], + b"\n\n" ] except Exception as ex: start_response('500 Internal Server Error', [