daimaou-project-5zk58s/endpoints/countries.post.py

15 lines
440 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from core.database import get_db
from schemas.country import CountryCreate
from helpers.country_helpers import create_country
router = APIRouter()
@router.post("/countries", status_code=201)
async def create_new_country(
country_data: CountryCreate,
db: Session = Depends(get_db)
):
new_country = create_country(db, country_data)
return new_country