所以我对Python Web服务器很陌生并且正在关注这个问题
How to setup a Raspberry Pi to receive webhooks
从Ifttt接收webhook以控制我的电视和AC,但我的服务器不会显示来自Ifttt服务器的任何消息。我已经检查过我的服务器是否可以从互联网上看到,我可以使用代理触发它。
Python代码:
from flask import Flask
import subprocess
app = Flask(__name__)
tv_Power = "irsend SEND_ONCE TV KEY_POWER"
AC_On = "irsend SEND_ONCE AC on on on on on on"
AC_Off = "irsend SEND_ONCE AC off off off off off off off off off off off off off"
@app.route('/', methods = ['POST'])
def index():
return 'Choose Option'
@app.route('/tv_Power',methods=['POST'])
def pow():
process = subprocess.Popen(tv_Power.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
return 'Changing TV State'
@app.route('/AC_On',methods=['POST'])
def acon():
process = subprocess.Popen(AC_On.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
return 'Turning AC On'
@app.route('/AC_Off',methods=['POST'])
def acoff():
process = subprocess.Popen(AC_Off.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
return 'Turning AC Off'
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
答案 0 :(得分:0)
您的所有路线都定义为POST。也许
methods=['POST','GET']
答案 1 :(得分:0)
以下是一些修复程序:
查看我的文章: IFTTT, Python, and Flask