所以我对 Python Web 服务器很陌生,并且一直在关注这个问题
从Ifttt接收 webhook以控制我的电视和 AC,但我的服务器没有显示来自Ifttt服务器的任何消息。我已经检查了我的服务器在互联网上是可见的,我可以使用代理来触发它。
蟒蛇代码:
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')
Ifttt 网络钩子设置: