示例#1
0
def mounted_api() -> Api:
    api = Api()
    api.register_component(MountedComponent)

    @api.route("/root-component")
    class RootView:
        async def on_get(self, req: Request, resp: Response, /,
                         **kw) -> Response:
            try:
                use_component(RootComponent)
            except KeyError:
                return resp.set_status(
                    HTTPStatus.NOT_FOUND).set_text("not found")
            return resp.set_status(HTTPStatus.OK).set_text("ok")
示例#2
0
def store_async(api: Api):
    api.register_component(StoreAsync)
    return StoreAsync