Initial commit: FishServer monorepo (FishAction, FishMeasure, fish_api)
Made-with: Cursor
This commit is contained in:
55
fish_api/app/routers/biomass.py
Normal file
55
fish_api/app/routers/biomass.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.state import app_state
|
||||
|
||||
router = APIRouter(prefix="/api/v1/biomass", tags=["biomass"])
|
||||
|
||||
|
||||
@router.get("/real/camera/")
|
||||
async def get_real_camera():
|
||||
"""双目实时结果(轮询最新一次 FishMeasure 完成快照)。"""
|
||||
m = app_state.last_measure
|
||||
if m.error:
|
||||
return {
|
||||
"code": 500,
|
||||
"msg": m.error,
|
||||
"data": {
|
||||
"result": [],
|
||||
"video_left": "",
|
||||
"video_right": "",
|
||||
},
|
||||
}
|
||||
return {
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"result": m.result,
|
||||
"video_left": m.video_left,
|
||||
"video_right": m.video_right,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@router.get("/health/result/")
|
||||
async def get_health_result():
|
||||
"""行为 / 健康结果(轮询最新一次 FishAction 完成快照)。"""
|
||||
h = app_state.last_health
|
||||
if h.error:
|
||||
return {
|
||||
"code": 500,
|
||||
"msg": h.error,
|
||||
"data": {
|
||||
"behavior_result": "",
|
||||
"health_result": "",
|
||||
},
|
||||
}
|
||||
return {
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"behavior_result": h.behavior_result,
|
||||
"health_result": h.health_result,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user