async def image():
     resp = await self.client.request("POST", "/downloadImage", data={
         "url": "https://nim.nosdn.127.net/NDA5MzEwOA==/bmltYV83MjUyMDE5NDYwXzE1NTU0Mjg5OTU1MDZfYjhjNzI3N2UtZjM4OC00YzA2LWE5NzMtYzM1YTQ5OWUyMDhl"
     })
     # logger.debug(req)
     # resp = await pocketHandler.downloadImage(req)
     logger.debug(resp)
     print(await resp.json())
Esempio n. 2
0
async def downloadAudio(requests: web.Request):
    """
    下载语音文件处理流程
    """
    logger.debug(requests)
    data = await requests.post()
    if "url" not in data:
        return web.json_response({"msg": "缺少请求参数"})

    logger.debug(data["url"])
    audioUrl = data["url"]

    try:
        data = await getData(audioUrl)
        filename = f"{filePrefix}/audio/{uuid.uuid1().hex}.aac"
        await saveFile(filename, data)
        jsonResp = {"path": filename}
        return web.json_response(jsonResp)
    except IOError as err:
        logger.error(f"语音文件下载失败, url: {audioUrl}, err: {err}", exc_info=True)
        raise web.HTTPInternalServerError(body={"msg": "下载语音出错"})