fix api update error
#!coding: utf-8
from __future__ import print_function, unicode_literals
import json
+import json.decoder
import os
import tornado.web
+from tornado.web import HTTPError
from bgmi import __version__, __admin_version__
from bgmi.config import DANMAKU_API_URL, BGMI_PATH, LANG
@@ -20,9 +22,9 @@ class BaseHandler(tornado.web.RequestHandler):
def get_json(self):
try:
- return json.loads(self.request.body.decode('utf-8'))
- except (json.JSONDecoder, ValueError):
- return {}
+ return json.loads(self.request.body)
+ except json.decoder.JSONDecodeError:
+ raise HTTPError(400)
def jsonify(self, data=None, **kwargs):
j = {
