mirror of
https://github.com/Sosokker/HomieCare.git
synced 2025-12-20 10:24:04 +01:00
Change endpoints name
This commit is contained in:
parent
c6adb4ed7a
commit
db67580aa2
@ -1,24 +1,14 @@
|
|||||||
import asyncio
|
from cv2 import VideoCapture, imencode
|
||||||
import cv2
|
|
||||||
import datetime
|
|
||||||
import os
|
|
||||||
|
|
||||||
from threading import Thread
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
||||||
from cv2 import VideoCapture, VideoWriter, imencode
|
|
||||||
|
|
||||||
from fastapi import APIRouter, BackgroundTasks, HTTPException
|
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
|
|
||||||
from scheme import Camera
|
from scheme import Camera
|
||||||
from database import minio_client
|
|
||||||
from config import VIDEO_BUCKET, TEMP_VIDEO_FILE
|
|
||||||
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
cameras: List[Camera] = []
|
cameras: list[Camera] = []
|
||||||
|
|
||||||
# --- UTILITY FUNCTIONS ---
|
# --- UTILITY FUNCTIONS ---
|
||||||
|
|
||||||
@ -30,7 +20,7 @@ def generate_camera_id() -> int:
|
|||||||
|
|
||||||
# --- ROUTER ENDPOINTS ---
|
# --- ROUTER ENDPOINTS ---
|
||||||
|
|
||||||
@router.post("/add_camera", response_model=dict)
|
@router.post("/add", response_model=dict)
|
||||||
async def add_camera(rtsp_link: str):
|
async def add_camera(rtsp_link: str):
|
||||||
if rtsp_link:
|
if rtsp_link:
|
||||||
id = generate_camera_id()
|
id = generate_camera_id()
|
||||||
@ -41,12 +31,12 @@ async def add_camera(rtsp_link: str):
|
|||||||
raise HTTPException(status_code=400, detail="Invalid RTSP link")
|
raise HTTPException(status_code=400, detail="Invalid RTSP link")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list_cameras", response_model=List[Camera])
|
@router.get("/list", response_model=list[Camera])
|
||||||
async def list_cameras() -> List[Camera]:
|
async def list_cameras() -> list[Camera]:
|
||||||
return cameras
|
return cameras
|
||||||
|
|
||||||
|
|
||||||
@router.get("/stream_video/{camera_id}")
|
@router.get("/stream/{camera_id}")
|
||||||
async def stream_video(camera_id: int) -> StreamingResponse:
|
async def stream_video(camera_id: int) -> StreamingResponse:
|
||||||
available_cameras = [camera.camera_id for camera in cameras]
|
available_cameras = [camera.camera_id for camera in cameras]
|
||||||
if camera_id in available_cameras:
|
if camera_id in available_cameras:
|
||||||
@ -73,7 +63,7 @@ async def stream_video(camera_id: int) -> StreamingResponse:
|
|||||||
raise HTTPException(status_code=404, detail="No cameras available")
|
raise HTTPException(status_code=404, detail="No cameras available")
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/disconnect_camera/{camera_id}", response_model=dict)
|
@router.delete("/remove/{camera_id}", response_model=dict)
|
||||||
async def disconnect_camera(camera_id: int) -> dict:
|
async def disconnect_camera(camera_id: int) -> dict:
|
||||||
for camera in cameras:
|
for camera in cameras:
|
||||||
if camera.camera_id == camera_id:
|
if camera.camera_id == camera_id:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user