botreascrch/pullbot.py

26 lines
892 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import Flask, jsonify, abort, request
from flask_cors import CORS, cross_origin
import requests
import json
app = Flask(__name__)
@app.route('/payload', methods=['POST'])
@cross_origin()
def push_deal():
payload = request.json
print(payload)
# 平台用户开发能力API接口
url_basic = 'https://forgeplus.trustie.net/api/users/{login}/statistics/develop.json'
# 提取事件数据找到pusher拼接得到完整的URL
login = payload['pusher']['login']
url = url_basic.format(login=login)
# requests请求header信息配置
header = {
'User-Agent': 'Mozilla/5.0',
'Content-Type': 'application/json',
'Accept': 'application/vnd.github.v3+json'
}
# 访问api接口获取本次pusher的开发能力信息
response = requests.get(url, headers=header)
return response.json()