about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/fastapi/responses.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/fastapi/responses.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/fastapi/responses.py')
-rw-r--r--.venv/lib/python3.12/site-packages/fastapi/responses.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/fastapi/responses.py b/.venv/lib/python3.12/site-packages/fastapi/responses.py
new file mode 100644
index 00000000..6c8db6f3
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/fastapi/responses.py
@@ -0,0 +1,48 @@
+from typing import Any
+
+from starlette.responses import FileResponse as FileResponse  # noqa
+from starlette.responses import HTMLResponse as HTMLResponse  # noqa
+from starlette.responses import JSONResponse as JSONResponse  # noqa
+from starlette.responses import PlainTextResponse as PlainTextResponse  # noqa
+from starlette.responses import RedirectResponse as RedirectResponse  # noqa
+from starlette.responses import Response as Response  # noqa
+from starlette.responses import StreamingResponse as StreamingResponse  # noqa
+
+try:
+    import ujson
+except ImportError:  # pragma: nocover
+    ujson = None  # type: ignore
+
+
+try:
+    import orjson
+except ImportError:  # pragma: nocover
+    orjson = None  # type: ignore
+
+
+class UJSONResponse(JSONResponse):
+    """
+    JSON response using the high-performance ujson library to serialize data to JSON.
+
+    Read more about it in the
+    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
+    """
+
+    def render(self, content: Any) -> bytes:
+        assert ujson is not None, "ujson must be installed to use UJSONResponse"
+        return ujson.dumps(content, ensure_ascii=False).encode("utf-8")
+
+
+class ORJSONResponse(JSONResponse):
+    """
+    JSON response using the high-performance orjson library to serialize data to JSON.
+
+    Read more about it in the
+    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
+    """
+
+    def render(self, content: Any) -> bytes:
+        assert orjson is not None, "orjson must be installed to use ORJSONResponse"
+        return orjson.dumps(
+            content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY
+        )