1 Star 0 Fork 0

笑着笑着就哭了/dailyuse-scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
interface.py.1 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
笑着笑着就哭了 提交于 2020-02-29 20:26 . 保存脚本
# -*- 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')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/erheihei/dailyuse-scripts.git
git@gitee.com:erheihei/dailyuse-scripts.git
erheihei
dailyuse-scripts
dailyuse-scripts
master

搜索帮助