服务端
import json
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
class compliance(RequestHandler):
def post(self):
jsonbyte = self.request.body
jsonstr = jsonbyte.decode('utf8') # 解码,二进制转为字符串
jsonobj = json.loads(jsonstr) # 将字符串转为json对象
text = jsonobj['data']
print(text)
result = json.dumps(text, ensure_ascii=False)
self.write(result)
def make_app():
urls = [
("/v1/compliance=/", compliance),
]
return Application(urls, debug=True)
if __name__ == '__main__':
app = make_app()
app.listen(10005)
IOLoop.instance().start()
客户端
# coding=utf-8
import json
import base64
import requests
url = 'http://192.168.1.201:10005/v1/compliance=/' # 年报
bodyData = {"data": '(四)年报显示,你公司“年初疫情高峰期购买的口罩设备价格较高,设备 出现减值准备计提”。请说明设备发生减值的时点、迹象、计提金额及减值测算过 程,以及2021 年以来该类业务的毛利率变化情况。',
}
date_json = json.dumps(bodyData)
r = requests.post(url, data=date_json)
data = json.loads(r.text)
print(data)
网友评论