This commit is contained in:
ywb
2026-06-02 14:52:10 +08:00
parent 0b5862b271
commit 525025a5f7
6 changed files with 141 additions and 58 deletions
+32
View File
@@ -1132,6 +1132,38 @@ def api_arm_camera_refresh():
return "", 404
@app.route("/api/camera/arm_preview")
def api_arm_camera_preview():
"""代理机械臂 MJPEG 视频流,供页面连续预览。"""
import requests
try:
upstream = requests.get(
ARM_CAMERA_CONFIG["url"],
stream=True,
timeout=(3, 10),
)
if upstream.status_code != 200:
upstream.close()
return "", 404
def generate():
try:
for chunk in upstream.iter_content(chunk_size=8192):
if chunk:
yield chunk
finally:
upstream.close()
return Response(
generate(),
mimetype="multipart/x-mixed-replace; boundary=frame",
headers={"Cache-Control": "no-cache, no-store, must-revalidate, max-age=0"},
)
except Exception as ex:
logger.error(f"arm_preview 失败: {ex}")
return "", 404
@app.route("/api/camera/qr_scan", methods=["GET"])
def api_qr_scan():
"""扫描一次二维码"""