72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
import requests, json
|
|
KEY = "dish_a4f7a1287198179fdc6a6571aa14064c2afc6338c6730e2b668ac5be15bdf769"
|
|
H = {"X-API-Key": KEY, "Accept": "application/json", "Content-Type": "application/json"}
|
|
base = "https://cpsb.ruimeida.cc"
|
|
|
|
# 1) bases with correct key
|
|
r = requests.get(base+"/api/public/bases", headers=H, timeout=15)
|
|
print("GET bases", r.status_code, r.text[:200])
|
|
|
|
# 2) meal schedules today
|
|
r = requests.get(base+"/api/public/meal-schedules/today", headers=H, params={"baseName":"奥体基地"}, timeout=15)
|
|
print("GET meal today", r.status_code, r.text[:400])
|
|
|
|
# 3) probe write/device endpoints
|
|
paths_get = [
|
|
"/api/public/devices",
|
|
"/api/public/device/status",
|
|
"/api/public/devices/status",
|
|
"/api/public/device-status",
|
|
]
|
|
paths_post = [
|
|
"/api/public/dish/recognize/result",
|
|
"/api/public/recognize/result",
|
|
"/api/public/recognition/result",
|
|
"/api/public/recognition-results",
|
|
"/api/public/devices/status",
|
|
"/api/public/device/status",
|
|
"/api/public/device-status",
|
|
"/api/public/devices/heartbeat",
|
|
"/api/public/devices/heartbeat",
|
|
]
|
|
payload_result = {
|
|
"requestId": "REQ_TEST",
|
|
"baseCode": "上海路基地-1788059884828-e55vu",
|
|
"baseName": "上海路基地",
|
|
"captureTime": "2026-09-23 15:00:00",
|
|
"sourceImage": "https://example.com/a.jpg",
|
|
"labeledImage": "https://example.com/b.jpg",
|
|
"dishCount": 1,
|
|
"dishes": [{"index":1,"name":"土豆丝","cropImage":"https://example.com/c.jpg"}],
|
|
}
|
|
payload_device = {
|
|
"deviceCode": "DEV_LOCAL_01",
|
|
"baseCode": "上海路基地-1788059884828-e55vu",
|
|
"baseName": "上海路基地",
|
|
"status": "online",
|
|
"lastHeartbeat": "2026-09-23 15:00:00",
|
|
}
|
|
for p in paths_get:
|
|
try:
|
|
r = requests.get(base+p, headers=H, timeout=10)
|
|
print("GET", p, r.status_code, (r.text or "")[:100].replace("\n"," "))
|
|
except Exception as e:
|
|
print("GET", p, e)
|
|
for p in paths_post:
|
|
body = payload_device if "device" in p or "heartbeat" in p else payload_result
|
|
try:
|
|
r = requests.post(base+p, headers=H, json=body, timeout=10)
|
|
print("POST", p, r.status_code, (r.text or "")[:120].replace("\n"," "))
|
|
except Exception as e:
|
|
print("POST", p, e)
|
|
try:
|
|
r = requests.put(base+p, headers=H, json=body, timeout=10)
|
|
print("PUT ", p, r.status_code, (r.text or "")[:120].replace("\n"," "))
|
|
except Exception as e:
|
|
print("PUT ", p, e)
|
|
try:
|
|
r = requests.patch(base+p, headers=H, json=body, timeout=10)
|
|
print("PATCH", p, r.status_code, (r.text or "")[:120].replace("\n"," "))
|
|
except Exception as e:
|
|
print("PATCH", p, e)
|