我如何设置bottle.py和Alexa来传递语音,以便可以通过if / elif语句对其进行解析?
我以前曾使用IFTTT通过Ngrok和Bottle.py向我的Pi发送JSON消息。收到触发器后,Bottle.py将执行命令(我已附加了以下代码的副本)。我一直试图将其迁移到Alexa技能,因为IFTTT要求每个小程序都使用一个单独的词组,我认为最好将其设置为Alexa技能。
from bottle import route, run, template, post, request
import os
import energenie as e
@route('/')
def do_get():
# get the body of the request
body = request.body.read()
# print the body
print body
@post('/post')
def do_post():
# get the body of the request
body = request.body.read()
# print the body
print body
list = body.split (",")
print list
print list[0]
if list[0] == 'computer light on':
e.switch_on(1)
elif list[0] == 'computer light off':
e.switch_off(0)
run(host='0.0.0.0', port=8080)
我已经建立了一个意图,并触发了端点并将其定向到Ngrok,但是我收到了Alexa的“向技术发送请求时发生了异常”。