我有一个 nodejs 端点,它将由一个带有 POST HTTP 调用的作业调用,该调用包含 JSON 格式的作业数据的详细信息?如何从 python 客户端监听 webhook(https 地址)以获取作业数据?
https://company/api/bats_push
app.post("/api/bats_push",(req, res) => {
//console.log("Calling bats_push...")
const d = {
method: req.method,
headers: req.headers,
query: req.query,
body: ''
}
req.on('data', (c) => {
d.body = d.body + c
});
req.on('end', () => {
DATA.push(d);
res.end('Saved');
});
});
蟒蛇客户端:
data = {'name': 'joe', 'age': 20}
webhook_url = 'http://localhost:3000/api/bats_push'
json_data = json.dumps(data)
print json_data
try:
r = requests.post(webhook_url,data=json_data.encode("utf8"),verify=False,headers={"Content-Type": "application/json"},timeout=10.0)
print "posted"
print(r.status_code, r.reason)
print r.url
except Exception as e:
print (e)
错误:-
HTTPConnectionPool(host='localhost', port=3000): Read timed out. (read timeout=10.0)
阿波罗的战车
HUH函数
慕娘9325324
相关分类