quart.wrappers.response module
- class quart.wrappers.response.DataBody(data: bytes)
Bases:
quart.wrappers.response.ResponseBody
- async make_conditional(begin: int, end: Optional[int]) int
- class quart.wrappers.response.FileBody(file_path: Union[str, os.PathLike], *, buffer_size: Optional[int] = None)
Bases:
quart.wrappers.response.ResponseBody
Provides an async file accessor with range setting.
The
Response.response
attribute must be async-iterable and yield bytes, which this wrapper does for a file. In addition it allows a range to be set on the file, thereby supporting conditional requests.- buffer_size
Size in bytes to load per iteration.
- buffer_size = 8192
- async make_conditional(begin: int, end: Optional[int]) int
- class quart.wrappers.response.IOBody(io_stream: _io.BytesIO, *, buffer_size: Optional[int] = None)
Bases:
quart.wrappers.response.ResponseBody
Provides an async file accessor with range setting.
The
Response.response
attribute must be async-iterable and yield bytes, which this wrapper does for a file. In addition it allows a range to be set on the file, thereby supporting conditional requests.- buffer_size
Size in bytes to load per iteration.
- buffer_size = 8192
- async make_conditional(begin: int, end: Optional[int]) int
- class quart.wrappers.response.IterableBody(iterable: Union[AsyncGenerator[bytes, None], Iterable])
- class quart.wrappers.response.Response(response: Optional[Union[quart.wrappers.response.ResponseBody, AnyStr, Iterable]] = None, status: Optional[int] = None, headers: Optional[Union[dict, werkzeug.datastructures.Headers]] = None, mimetype: Optional[str] = None, content_type: Optional[str] = None)
Bases:
werkzeug.sansio.response.Response
This class represents a response.
It can be subclassed and the subclassed used in preference by replacing the
response_class
with your subclass.- automatically_set_content_length
If False the content length header must be provided.
- default_status
The status code to use if not provided.
- default_mimetype
The mimetype to use if not provided.
- Type
t.Optional[str]
- implicit_sequence_conversion
Implicitly convert the response to a iterable in the get_data method, to allow multiple iterations.
- async add_etag(overwrite: bool = False, weak: bool = False) None
- automatically_set_content_length = True
- property data: bytes
- data_body_class
alias of
quart.wrappers.response.DataBody
- default_mimetype: t.Optional[str] = 'text/html'
the default mimetype if none is provided.
- file_body_class
alias of
quart.wrappers.response.FileBody
- async freeze() None
Freeze this object ready for pickling.
- async get_data(as_text: Literal[True]) str
- async get_data(as_text: Literal[False]) bytes
- async get_data(as_text: bool = True) AnyStr
Return the body data.
- async get_json(force: bool = False, silent: bool = False) Any
Parses the body data as JSON and returns it.
- Parameters
force – Force JSON parsing even if the mimetype is not JSON.
silent – Do not trigger error handling if parsing fails, without this the
on_json_loading_failed()
will be called on error.
- headers: Headers
- implicit_sequence_conversion = True
- io_body_class
alias of
quart.wrappers.response.IOBody
- async iter_encode() AsyncGenerator[bytes, None]
- iterable_body_class
alias of
quart.wrappers.response.IterableBody
- property json: Any
- json_module = <module 'quart.json' from '/build/quart-HrGHdM/quart-0.18.3/.pybuild/cpython3_3.11_quart/build/quart/json/__init__.py'>
- async make_conditional(request: Request, accept_ranges: Union[bool, str] = False, complete_length: Optional[int] = None) Response
- async make_sequence() None
- property max_cookie_size: int
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- response: ResponseBody
- set_data(data: AnyStr) None
Set the response data.
This will encode using the
charset
.
- timeout: Any
- class quart.wrappers.response.ResponseBody
Bases:
abc.ABC
Base class wrapper for response body data.
This ensures that the following is possible (as Quart assumes so when returning the body to the ASGI server
- async with wrapper as response:
- async for data in response:
send(data)