Return a requests.Response object from Flask

Ok, found it:

If a tuple is returned the items in the tuple can provide extra information. Such tuples have to be in the form (response, status, headers). The status value will override the status code and headers can be a list or dictionary of additional header values.

(Flask docs.)

So

return (resp.text, resp.status_code, resp.headers.items())

seems to do the trick.

Leave a Comment