代码拉取完成,页面将自动刷新
# -*- coding:utf-8 -*-
import flask, json
from flask import request
import re, requests
webhook = "https://oapi.dingtalk.com/robot/send?access_token=bd38f7e0be7a15dd0db6d8d89a9bff3d722ad96c763a7492ce5a5c0822729744"
mobile = "13588287451"
# 创建一个服务,把当前这个python文件当做一个服务
server = flask.Flask(__name__)
@server.route('/callback', methods=['get', 'post'])
def callback():
code = "200"
if request.method == 'POST':
params = request.args.to_dict()
print(params)
#判断类型
if re.findall(str(params['Label']), "sexy"):
params['Label'] = "性感"
elif re.findall(str(params['Label']), "porn"):
params['Label'] = "涉黄"
elif re.findall(str(params['Label']), "normal"):
params['Label'] = "正常"
else:
params['Label'] = "未知"
#判断是否需要复审
if re.findall(str(params['Review']), "false"):
params['Review'] = "不需要"
else:
params['Review'] = "需要"
#替换字典key
params.update(存储空间 = params.pop("Hub"), 完整流名 = params.pop("StreamId"), 房间号 = params.pop("Stream"), 准确率 = params.pop("Rate"), 人工复审 = params.pop("Review"), 时间 = params.pop("Time"),类型 = params.pop("Label"), 文件 = params.pop("Ts"),)
result = ""
for key, value in params.items():
value = "".join(value)
result += str(key) +": "+ str(value) + "\n"
Robot_Send(result)
return json.dumps({"code": code}, ensure_ascii=False)
def Robot_Send(message):
url = webhook
headers = {
"Content-Type": "application/json ;charset=utf-8 "
}
data = {
"msgtype": "text",
"text": {"content": message},
"at": {
"atMobiles": [ mobile ],
"isAtAll": False
}
}
format_data = json.dumps(data, sort_keys=True,indent = 4) #转为json
res = requesTs.post(url, data=format_data, headers=headers)
return res
if __name__ == '__main__':
server.run(debug=True, port=8888, host='0.0.0.0')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。