-
This commit is contained in:
@@ -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():
|
||||
"""扫描一次二维码"""
|
||||
|
||||
Reference in New Issue
Block a user