防火墙和端口
1.安装防火墙
安装iptables-services :
2.防火墙基本操作
查看版本: firewall-cmd --version
显示状态: firewall-cmd --state
查看所有打开的端口: netstat -anp
开启防火墙 systemctl start firewalld
关闭防火墙 systemctl stop firewalld
开启防火墙 service firewalld start
若遇到无法开启
先用:systemctl unmask firewalld.service
然后:systemctl start firewalld.service
3.端口查询
查询指定端口是否已开 firewall-cmd --query-port=666/tcp
提示yes or no
查询所有开启的端口 netstat -anp
4.开启端口
如果上面端口查询没有开启的话,需要重新开启一下
开启端口命令
添加 firewall-cmd --zone=public --add-port=80/tcp --permanent (–permanent永久生效,没有此参数重启后失效)
重新载入 firewall-cmd --reload
查看 firewall-cmd --zone= public --query-port=80/tcp
删除 firewall-cmd --zone= public --remove-port=80/tcp --permanent
服务端用了flask框架 具体代码如下
阿里云技能平台webhook的post请求响应时间为两秒钟
from flask import Flask, request
import time
app = Flask(__name__)@app.route('/')
def hello_world():return 'hello world'@app.route('/aligenie/bafcae57d9828b629375532832e3f0d7.txt', methods=['get'])
def aligenie():return "Jfc4Z4Ur15JwUBuvUQD5wg7Nu8+l+HscqYlfofbyJdYwYnkEj1neAyykUNteoRrK"@app.route('/register', methods=['POST'])
def register():print(request.form)print(request.data)retunStr = "hello"# print(type(request.data))print(time.ctime())if isinstance(request.data,bytes):# getdict = eval(request.data.decode("utf-8"))data = str(request.data.decode("utf-8"))data = data.replace("false","False")data = data.replace("true","True")# print(type(data))# print(data)# print(eval(data))else:getdict = eval(str(request.data))getdict = eval(data)# getdict = eval(str(request.data))# print(type(getdict))retunStr = getdict.get("slotEntities")[0].get("slotValue")redata ={"returnCode": "0","returnErrorSolution": "","returnMessage": "","returnValue": {"reply": retunStr,"resultType": "RESULT","actions": [{"name": "audioPlayGenieSource","properties": {"audioGenieId": "123"}}],"properties": {},"executeCode": "SUCCESS","msgInfo": ""}}# print(redata)# time.sleep(10)print(time.ctime())return redataif __name__ == '__main__':app.run(host="youhost",port=8888,debug=True)
阿里云技能平台设置对应的URL