0
from flask import Flask
from flask_restful import Resource, Api
import subprocess
app = Flask(__name__)
api = Api(app)
class SlackReport(Resource):
def get(self):
subprocess.Popen(['python', 'ingestion_ice3_check.py'])
return 'Request submitted'
api.add_resource(SlackReport, '/slackReport')
if __name__ == '__main__':
app.run(debug=True)
如果我執行:
curl --ipv4 http://127.0.0.1:5000/slackReport
服務器發送的響應,但如果我執行來自同一局域網中另一臺機器的相同命令我收到'連接被拒絕'消息
$ curl -X GET http://10.113.12.20:5000/slackReport
curl: (7) Failed to connect to 10.113.12.20 port 5000: Connection refused
如果我請求資源fr OM本地主機,我可以看到從服務器
127.0.0.1 - - [28/Sep/2017 18:15:02] "GET /slackReport HTTP/1.1" 200 -
的調試控制檯的要求但是,如果我從遠程計算機請求相同的資源,我可以看到該端口的數據包,但燒瓶服務器沒有收到任何東西。
$ sudo tcpdump -i ens192 port 5000
18:17:53.132514 IP 10.113.12.25.37096 > tl020dash.commplex-main: Flags [S], seq 3147843104, win 14600, options [mss 1460,sackOK,TS val 822032144 ecr 0,nop,wscale 7], length 0
這是
sudo netstat -tnlp | grep :5000
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 21872/python
的可能的複製[瓶 - 配置開發服務器是在網絡上可見](https://stackoverflow.com/questions/7023052/flask-configure-dev-server-to-be-visible-across -網絡) –