import requests import json import config NOTIFY_URL = config.config["NOTIFY_URL"] def send_action_ws(action_type, action_content): # 定义要发送的数据 data = {"type": action_type, "content": action_content} # 将数据转换为 JSON 格式 json_data = json.dumps(data) # 设置请求头部 headers = { "Content-Type": "application/json" } # 发送 POST 请求 response = requests.post(NOTIFY_URL, data=json_data, headers=headers) # 检查响应状态码 if response.status_code == 200: # 打印响应内容 print("发送语义结果到websocket服务成功") else: print("发送语义结果到websocket服务失败,Error http code:", response.status_code)