From 5e6280166689c732b3188042ad060a24946351f9 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 21 Dec 2014 20:19:30 +0100 Subject: [PATCH] Send data through finish not write --- couchpotato/api.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/couchpotato/api.py b/couchpotato/api.py index fbe18b4a..4efd603b 100644 --- a/couchpotato/api.py +++ b/couchpotato/api.py @@ -141,14 +141,12 @@ class ApiHandler(RequestHandler): jsonp_callback = self.get_argument('callback_func', default = None) if jsonp_callback: - self.write(str(jsonp_callback) + '(' + json.dumps(result) + ')') - self.set_header("Content-Type", "text/javascript") - self.finish() + self.set_header('Content-Type', 'text/javascript') + self.finish(str(jsonp_callback) + '(' + json.dumps(result) + ')') elif isinstance(result, tuple) and result[0] == 'redirect': self.redirect(result[1]) else: - self.write(result) - self.finish() + self.finish(result) except UnicodeDecodeError: log.error('Failed proper encode: %s', traceback.format_exc()) except: