From 7b49a8ab58de1bde582e0078fa805da9589d5176 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Tue, 9 Jan 2024 12:41:32 -0500 Subject: [PATCH] add JSONResponseNoASCII --- core/title.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/title.py b/core/title.py index 8bead43..7aeb433 100644 --- a/core/title.py +++ b/core/title.py @@ -1,4 +1,5 @@ -from typing import Dict, List, Tuple +from typing import Dict, List, Tuple, Any +import json import logging, coloredlogs from logging.handlers import TimedRotatingFileHandler from starlette.requests import Request @@ -9,6 +10,15 @@ from core.config import CoreConfig from core.data import Data from core.utils import Utils +class JSONResponseNoASCII(Response): + media_type = "application/json" + + def render(self, content: Any) -> bytes: + return json.dumps( + content, + ensure_ascii=False, + ).encode("utf-8") + class BaseServlet: def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: self.core_cfg = core_cfg