feat: Add POST /route endpoint

This commit is contained in:
Backend IM Bot 2025-04-09 13:19:34 +00:00
parent 4ec906e9b2
commit 9b0089a6bb

View File

@ -1,10 +1,5 @@
Here is the Python code for the FastAPI endpoint to handle routing on a logistic app:
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.route import Route
from schemas.route import RouteSchema, RouteCreate
from helpers.route_helpers import get_all_routes, create_route
@ -16,4 +11,9 @@ async def create_new_route(
db: Session = Depends(get_db)
):
new_route = create_route(db=db, route=route)
return new_route
return new_route
@router.get("/routes", status_code=200, response_model=List[RouteSchema])
async def get_routes(db: Session = Depends(get_db)):
routes = get_all_routes(db)
return routes