Returns response object with body in text format. Args: body (str): Response data. status (int, optional): HTTP response code. Defaults to `200`. headers (Dict[str, str], optional): Custom HTTP headers. Defaults to `None`. content_type (str, optional): The conten
(
body: str,
status: int = 200,
headers: dict[str, str] | None = None,
content_type: str = "text/plain; charset=utf-8",
)
| 65 | |
| 66 | |
| 67 | def text( |
| 68 | body: str, |
| 69 | status: int = 200, |
| 70 | headers: dict[str, str] | None = None, |
| 71 | content_type: str = "text/plain; charset=utf-8", |
| 72 | ) -> HTTPResponse: |
| 73 | """Returns response object with body in text format. |
| 74 | |
| 75 | Args: |
| 76 | body (str): Response data. |
| 77 | status (int, optional): HTTP response code. Defaults to `200`. |
| 78 | headers (Dict[str, str], optional): Custom HTTP headers. Defaults to `None`. |
| 79 | content_type (str, optional): The content type (string) of the response. Defaults to `"text/plain; charset=utf-8"`. |
| 80 | |
| 81 | Returns: |
| 82 | HTTPResponse: A response object with body in text format. |
| 83 | |
| 84 | Raises: |
| 85 | TypeError: If the body is not a string. |
| 86 | """ # noqa: E501 |
| 87 | if not isinstance(body, str): |
| 88 | raise TypeError( |
| 89 | f"Bad body type. Expected str, got {type(body).__name__})" |
| 90 | ) |
| 91 | |
| 92 | return HTTPResponse( |
| 93 | body, status=status, headers=headers, content_type=content_type |
| 94 | ) |
| 95 | |
| 96 | |
| 97 | def raw( |
searching dependent graphs…