faust.web.base¶
Base interface for Web server and views.
-
class
faust.web.base.Response[source]¶ Web server response and status.
-
abstract property
headers¶ Return mapping of response HTTP headers. :rtype:
MutableMapping[~KT, ~VT]
-
abstract property
-
class
faust.web.base.BlueprintManager(initial: Iterable[Tuple[str, Union[_T, str]]] = None) → None[source]¶ Manager of all blueprints.
-
class
faust.web.base.Web(app: faust.types.app.AppT, **kwargs: Any) → None[source]¶ Web server and HTTP interface.
-
default_blueprints= [('/router', 'faust.web.apps.router:blueprint'), ('/table', 'faust.web.apps.tables.blueprint')]¶
-
production_blueprints= [('', 'faust.web.apps.production_index:blueprint')]¶
-
debug_blueprints= [('/graph', 'faust.web.apps.graph:blueprint'), ('', 'faust.web.apps.stats:blueprint')]¶
-
content_separator= b'\r\n\r\n'¶
-
header_separator= b'\r\n'¶
-
header_key_value_separator= b': '¶
-
abstract
text(value: str, *, content_type: str = None, status: int = 200, reason: str = None, headers: MutableMapping = None) → faust.web.base.Response[source]¶ Create text response, using “text/plain” content-type.
- Return type
-
abstract
html(value: str, *, content_type: str = None, status: int = 200, reason: str = None, headers: MutableMapping = None) → faust.web.base.Response[source]¶ Create HTML response from string,
text/htmlcontent-type.- Return type
-
abstract
json(value: Any, *, content_type: str = None, status: int = 200, reason: str = None, headers: MutableMapping = None) → faust.web.base.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: str = None, status: int = 200, reason: str = None, headers: MutableMapping = None) → faust.web.base.Response[source]¶ Create new
bytesresponse - for binary data.- Return type
-
abstract
bytes_to_response(s: bytes) → faust.web.base.Response[source]¶ Deserialize HTTP response from byte string.
- Return type
-
abstract
response_to_bytes(response: faust.web.base.Response) → bytes[source]¶ Serialize HTTP response into byte string.
- Return type
-
abstract
route(pattern: str, handler: Callable, cors_options: Mapping[str, faust.types.web.ResourceOptions] = None) → None[source]¶ Add route for handler.
- Return type
None
-
abstract
add_static(prefix: str, path: Union[pathlib.Path, str], **kwargs: Any) → None[source]¶ Add static route.
- Return type
None
-
abstract async
read_request_content(request: faust.web.base.Request) → bytes[source]¶ Read HTTP body as bytes.
- Return type
-
add_view(view_cls: Type[faust.types.web.View], *, prefix: str = '', cors_options: Mapping[str, faust.types.web.ResourceOptions] = None) → faust.types.web.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
TypeErrorwill be raised.- Return type
-
logger= <Logger faust.web.base (WARNING)>¶
-