Spaces:
Running
Running
Download .pythonlibs/lib/python3.10/site-packages/fastapi/responses.py from cloudtheboi/Lofi4All: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/cloudtheboi/Lofi4All/resolve/main/.pythonlibs/lib/python3.10/site-packages/fastapi/responses.py
- Command line
-
hf download hf://spaces/cloudtheboi/Lofi4All/.pythonlibs/lib/python3.10/site-packages/fastapi/responses.py
-
curl -L -o responses.py https://huggingface.co/spaces/cloudtheboi/Lofi4All/resolve/main/.pythonlibs/lib/python3.10/site-packages/fastapi/responses.py
1.24 kB
| 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): | |
| 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): | |
| 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 | |
| ) | |