faust.web.drivers.aiohttp
¶
Web driver using https://pypi.org/project/aiohttp/.
- class faust.web.drivers.aiohttp.Web(app: AppT, **kwargs: Any)[source]¶
Web server and framework implementation using https://pypi.org/project/aiohttp/.
- property cors: CorsConfig¶
Return CORS config object. :rtype:
CorsConfig
- async on_start() None [source]¶
Call when the embedded web server starts.
Only used for faust worker, not when using
wsgi()
.- Return type:
None
- async wsgi() Any [source]¶
Call WSGI handler.
Used by https://pypi.org/project/gunicorn/ and other WSGI compatible hosts to access the Faust web entry point.
- Return type:
- text(value: str, *, content_type: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[MutableMapping] = None) Response [source]¶
Create text response, using “text/plain” content-type.
- Return type:
- html(value: str, *, content_type: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[MutableMapping] = None) Response [source]¶
Create HTML response from string,
text/html
content-type.- Return type:
- json(value: Any, *, content_type: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[MutableMapping] = None) Any [source]¶
Create new JSON response.
Accepts any JSON-serializable value and will automatically serialize it for you.
The content-type is set to “application/json”.
- Return type:
- bytes(value: bytes, *, content_type: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[MutableMapping] = None) Response [source]¶
Create new
bytes
response - for binary data.- Return type:
- async read_request_content(request: Request) bytes [source]¶
Return the request body as bytes.
- Return type:
- route(pattern: str, handler: Callable, cors_options: Optional[Mapping[str, ResourceOptions]] = None) None [source]¶
Add route for web view or handler.
- Return type:
None
- add_static(prefix: str, path: Union[Path, str], **kwargs: Any) None [source]¶
Add route for static assets.
- Return type:
None
- bytes_to_response(s: bytes) Response [source]¶
Deserialize byte string back into a response object.
- Return type:
- response_to_bytes(response: Response) bytes [source]¶
Convert response to serializable byte string.
The result is a byte string that can be deserialized using
bytes_to_response()
.- Return type:
- logger: logging.Logger = <Logger faust.web.drivers.aiohttp (WARNING)>¶