Add GET endpoint for /country
This commit is contained in:
parent
f87a8b0c9c
commit
d1759c3062
@ -1,7 +1,19 @@
|
|||||||
from fastapi import APIRouter
|
# Entity: Country
|
||||||
|
|
||||||
router = APIRouter();
|
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.get("/country")
|
router = APIRouter()
|
||||||
def get_countries():
|
|
||||||
return ["USA", "Canada", "Germany", "France", "Japan", "Australia"]
|
@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
|
Loading…
x
Reference in New Issue
Block a user