from typing import Any import random from fastapi import APIRouter from fastapi.responses import JSONResponse from fastapi import status from pydantic import BaseModel from app.services.tjnetwork import ( get_all_sensor_placements, get_all_burst_locate_results, ) router = APIRouter() @router.get("/getjson/") async def fastapi_get_json(): return JSONResponse( status_code=status.HTTP_400_BAD_REQUEST, content={ "code": 400, "message": "this is message", "data": 123, }, ) @router.get("/getallsensorplacements/") async def fastapi_get_all_sensor_placements(network: str) -> list[dict[Any, Any]]: return get_all_sensor_placements(network) @router.get("/getallburstlocateresults/") async def fastapi_get_all_burst_locate_results(network: str) -> list[dict[Any, Any]]: return get_all_burst_locate_results(network) class Item(BaseModel): str_info: str @router.post("/test_dict/") async def fastapi_test_dict(data: Item) -> dict[str, str]: item = data.dict() return item @router.get("/getrealtimedata/") async def fastapi_get_realtimedata(): data = [random.randint(0, 100) for _ in range(100)] return data @router.get("/getsimulationresult/") async def fastapi_get_simulationresult(): data = [random.randint(0, 100) for _ in range(100)] return data