19 lines
559 B
Python
19 lines
559 B
Python
# Entity: Country
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from models.country import Country
|
|
from schemas.country import CountrySchema
|
|
from helpers.country_helpers import get_countries_by_name_start
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/country", response_model=List[CountrySchema])
|
|
async def get_countries(
|
|
search: str = None,
|
|
db: Session = Depends(get_db)
|
|
):
|
|
countries = get_countries_by_name_start(db, search)
|
|
return countries |