faust.web.base
¶
Base interface for Web server and views.
- class faust.web.base.BlueprintManager(initial: Optional[Iterable[Tuple[str, Union[BlueprintT, str]]]] = None)[source]¶
Manager of all blueprints.
- class faust.web.base.Request[source]¶
HTTP Request.
- abstract property match_info: Mapping[str, str]¶
Return match info from URL route as a mapping. :rtype:
_GenericAlias
[str
,str
]
- class faust.web.base.Response[source]¶
Web server response and status.
- abstract property headers: MutableMapping¶
Return mapping of response HTTP headers. :rtype:
_SpecialGenericAlias
- abstract property content_length: Optional[int]¶
Return the size of the response body. :rtype:
_UnionGenericAlias
[int
,None
]
- abstract property charset: Optional[str]¶
Return the response character set. :rtype:
_UnionGenericAlias
[str
,None
]
- class faust.web.base.Web(app: AppT, **kwargs: Any)[source]¶
Web server and HTTP interface.
- default_blueprints: ClassVar[Iterable[Tuple[str, Union[BlueprintT, str]]]] = [('/router', 'faust.web.apps.router:blueprint'), ('/table', 'faust.web.apps.tables.blueprint')]¶
- production_blueprints: ClassVar[Iterable[Tuple[str, Union[BlueprintT, str]]]] = [('', 'faust.web.apps.production_index:blueprint')]¶
- debug_blueprints: ClassVar[Iterable[Tuple[str, Union[BlueprintT, str]]]] = [('/graph', 'faust.web.apps.graph:blueprint'), ('', 'faust.web.apps.stats:blueprint')]¶
- views: MutableMapping[str, View]¶
- reverse_names: MutableMapping[str, str]¶
- blueprints: BlueprintManager¶
- abstract 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:
- abstract 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:
- abstract json(value: Any, *, content_type: Optional[str] = None, status: int = 200, reason: Optional[str] = None, headers: Optional[MutableMapping] = None) Response [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:
- abstract 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:
- abstract bytes_to_response(s: bytes) Response [source]¶
Deserialize HTTP response from byte string.
- Return type:
- abstract response_to_bytes(response: Response) bytes [source]¶
Serialize HTTP response into byte string.
- Return type:
- abstract route(pattern: str, handler: Callable, cors_options: Optional[Mapping[str, ResourceOptions]] = None) None [source]¶
Add route for handler.
- Return type:
None
- abstract add_static(prefix: str, path: Union[Path, str], **kwargs: Any) None [source]¶
Add static route.
- Return type:
None
- abstract async read_request_content(request: Request) bytes [source]¶
Read HTTP body as bytes.
- Return type:
- add_view(view_cls: Type[View], *, prefix: str = '', cors_options: Optional[Mapping[str, ResourceOptions]] = None) View [source]¶
Add route for view.
- Return type:
- url_for(view_name: str, **kwargs: Any) str [source]¶
Get URL by view name.
If the provided view name has associated URL parameters, those need to be passed in as kwargs, or a
TypeError
will be raised.- Return type:
- logger: logging.Logger = <Logger faust.web.base (WARNING)>¶