forked from Dniel97/artemis
add JSONResponseNoASCII
This commit is contained in:
parent
f65aa4d60a
commit
7b49a8ab58
@ -1,4 +1,5 @@
|
|||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List, Tuple, Any
|
||||||
|
import json
|
||||||
import logging, coloredlogs
|
import logging, coloredlogs
|
||||||
from logging.handlers import TimedRotatingFileHandler
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
@ -9,6 +10,15 @@ from core.config import CoreConfig
|
|||||||
from core.data import Data
|
from core.data import Data
|
||||||
from core.utils import Utils
|
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:
|
class BaseServlet:
|
||||||
def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None:
|
def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None:
|
||||||
self.core_cfg = core_cfg
|
self.core_cfg = core_cfg
|
||||||
|
Loading…
Reference in New Issue
Block a user