Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3dc967a

Browse files
monkey patch to fix tornado ensure_ascii
1 parent df50767 commit 3dc967a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎web/server.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import os
1111
import contextlib
1212
import logging
13+
import json
1314

1415
import redis
1516
import pymongo
1617
from http import HTTPStatus
1718
from concurrent.futures import ThreadPoolExecutor
1819
from tornado import web, ioloop, httpserver, gen, options
1920
from tornado.log import enable_pretty_logging
20-
21+
fromtornadoimportescape
2122
from tornado.concurrent import run_on_executor
2223
from apscheduler.schedulers.background import BackgroundScheduler
2324

@@ -220,8 +221,14 @@ def get(self):
220221
class NameHandler(BaseHandler):
221222
executor = ThreadPoolExecutor(50)
222223

224+
@staticmethod
225+
def json_encode(value):
226+
return json.dumps(value, ensure_ascii=False)
227+
223228
@run_on_executor()
224-
def get_top_resource(self):
229+
def get_names(self):
230+
escape.json_encode = self.json_encode
231+
225232
if self.get_query_argument("human", None):
226233
aggregation = [
227234
{
@@ -260,7 +267,7 @@ def get_top_resource(self):
260267

261268
@gen.coroutine
262269
def get(self):
263-
resp = yield self.get_top_resource()
270+
resp = yield self.get_names()
264271
self.write(resp)
265272

266273

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /