# 示例:Flask 接口 (Python)
|
from flask import Flask, jsonify
|
import pymysql
|
|
app = Flask(__name__)
|
|
@app.route('/check-error-report')
|
def check_maq_report():
|
try:
|
conn = pymysql.connect(host='47.99.65.48', user='RemoteUser', password='TAI#wzp@2020', database='ots-sand')
|
cursor = conn.cursor()
|
cursor.execute("""
|
SELECT COUNT(*) FROM `t_exam_report`
|
WHERE finish = 1
|
AND product_name LIKE '%MAQ%'
|
AND question_report LIKE '[{"questionOrder":0,%'
|
""")
|
count = cursor.fetchone()[0]
|
conn.close()
|
|
if count > 1:
|
# 返回错误状态让 Uptime Kuma 告警
|
return jsonify({"status": "error", "count": count}), 500
|
else:
|
return jsonify({"status": "ok", "count": count}), 200
|
except Exception as e:
|
return jsonify({"error": str(e)}), 500
|
|
|
if __name__ == '__main__':
|
app.run(host='0.0.0.0', port=5000)
|