feat: Add POST /route endpoint

This commit is contained in:
Backend IM Bot 2025-04-09 13:19:28 +00:00
parent 0d5d94b4e3
commit 66038cc83b

View File

@ -0,0 +1,19 @@
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
router = APIRouter()
@router.post("/route", status_code=201, response_model=RouteSchema)
async def create_new_route(
route: RouteCreate,
db: Session = Depends(get_db)
):
new_route = create_route(db=db, route=route)
return new_route