From 64b32771bff52a9cd9e404c7c044b5c1cf5f55f5 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 28 Jun 2019 19:02:56 +0200 Subject: [PATCH] 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. --- redirector/redirector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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', [ -- 2.39.5