Merge pull request #255 from YunoHost/raw_http_responses

Allow python functions to return a raw HTTPResponse
This commit is contained in:
Alexandre Aubin 2020-09-16 17:41:39 +02:00 committed by GitHub
commit 6b99f8b77d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -577,6 +577,9 @@ def format_for_response(content):
return "" return ""
response.status = 200 response.status = 200
if isinstance(content, HTTPResponse):
return content
# Return JSON-style response # Return JSON-style response
response.content_type = "application/json" response.content_type = "application/json"
return json_encode(content, cls=JSONExtendedEncoder) return json_encode(content, cls=JSONExtendedEncoder)