feat: Add POST /route endpoint
This commit is contained in:
parent
0d5d94b4e3
commit
66038cc83b
@ -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
|
Loading…
x
Reference in New Issue
Block a user