123456789101112131415161718192021222324252627282930313233343536 |
- from simple_http_server import request_map
- from simple_http_server import Request
- import json
- import logging
- from mqtthelper import my_helper
- # import paho.mqtt.client as mqtt
- @request_map("/aligenieservice", method=["GET", "POST", "PUT"])
- def handle(request=Request()):
- logger = logging.getLogger()
- data = json.loads(request.body)
- logger.info(data)
- intentName = data['intentName']
- slotEntry = data['slotEntities'][0]
- standardValue = slotEntry['standardValue']
- slotValue = slotEntry['slotValue']
- standardValue = standardValue.replace("空格"," ")
- slotValue = slotValue.replace("空格"," ")
- payloadContent = '{\"intentName\":\"'+intentName+"\",\"standardValue\":\""+standardValue+"\",\"slotValue\":\""+slotValue+"\"}"
- my_helper.send(content=payloadContent)
- # client = mqtt.Client()
- # client.connect("10.8.8.4",1883,60)
- # client.publish("pccontrol",payload=payloadContent)
- replyContent = "正在为你打开"+slotValue
- response = {
- "returnCode": "0",
- "returnErrorSolution": "",
- "returnMessage": "",
- "returnValue": {
- "reply": replyContent,
- "resultType": "RESULT",
- "executeCode": "SUCCESS",
- "msgInfo": ""
- }
- }
- return response
|