调用RESTful API

用于调用网关提供的RESTful API。通过此接口可以调用网关内micropython模块未封装的接口。

参考 RESTful API

示例

 1import asyncio
 2import cassiablue
 3
 4
 5async def cassia_info():
 6    url = "/cassia/info"
 7    ok, ret = await cassiablue.send_cmd(url)
 8    print(type(ok), ok, type(ret), ret)
 9
10
11async def main():
12    print("start send cmd")
13    url = "/cassia/info"
14    ok, ret = await cassiablue.send_cmd(url)
15    print("send cmd done:", type(ok), ok, type(ret), ret)
16
17
18asyncio.run(main())

API

async cassiablue.send_cmd(path: str, method: str | None = 'GET', query: str | None = None, body: str | None = None) tuple[ok: bool, result: str]

用于调用网关提供的RESTful API。

Parameters:
  • path: API路径

  • method: HTTP方法

  • query: query参数

  • body: body参数

返回:

  • ok: 是否执行成功

  • result: 执行结果