#这里的self是tornado.web.RequestHandler
async def toSave(self,text,content):
http_client = tornado.httpclient.AsyncHTTPClient()
log.debug('调用case_analysis接口')
host = self.request.host
url = "自己想请求的url"
cookie = self.request.headers['Cookie']
headers = {'Content-Type': 'application/json','Cookie':cookie}
body = {"text":text,"content":content}
post_body = json.dumps(body, ensure_ascii=False)
resp = await tornado.gen.Task(
http_client.fetch,
url,
headers=headers,
method="POST",
body=post_body,
)
return json.loads(resp.body.decode())
tornado构造中转接口,带自己的cookie信息,并发送json数据
最新推荐文章于 2025-02-28 00:15:00 发布