Update code in endpoints/routeoptimization.post.py
This commit is contained in:
parent
e5dec77ba5
commit
22c452ab23
@ -0,0 +1,35 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
routes = [] # In-memory storage
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/routeoptimization")
|
||||
async def optimize_route(
|
||||
start_point: str = "origin",
|
||||
end_point: str = "destination",
|
||||
waypoints: list = []
|
||||
):
|
||||
"""Demo route optimization endpoint"""
|
||||
if not start_point or not end_point:
|
||||
raise HTTPException(status_code=400, detail="Invalid route parameters")
|
||||
|
||||
route_id = len(routes) + 1
|
||||
optimized_route = {
|
||||
"id": route_id,
|
||||
"start": start_point,
|
||||
"end": end_point,
|
||||
"waypoints": waypoints,
|
||||
"disabled": False
|
||||
}
|
||||
routes.append(optimized_route)
|
||||
|
||||
return {
|
||||
"message": "Route optimized successfully",
|
||||
"route_id": route_id,
|
||||
"path": [start_point] + waypoints + [end_point],
|
||||
"features": {
|
||||
"distance": 100,
|
||||
"duration": 3600
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user