Update code in endpoints/store.get.py
This commit is contained in:
parent
d8c1e87cd5
commit
f4ee838e58
@ -1,13 +1,21 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from core.database import get_db
|
||||||
from models.country import Country
|
from models.country import Country
|
||||||
from schemas.country import CountrySchema
|
from schemas.country import CountrySchema
|
||||||
from helpers.country_helpers import get_asian_countries
|
from helpers.country_helpers import get_asian_countries
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.get("/store", response_model=List[CountrySchema], status_code=200)
|
@router.get("/store", response_model=List[CountrySchema])
|
||||||
async def get_asian_countries_list():
|
async def get_asian_countries_list(
|
||||||
"""Get list of countries in Asia"""
|
db: Session = Depends(get_db)
|
||||||
countries = get_asian_countries()
|
):
|
||||||
|
countries = get_asian_countries(db)
|
||||||
|
if not countries:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
|
detail="No Asian countries found"
|
||||||
|
)
|
||||||
return countries
|
return countries
|
Loading…
x
Reference in New Issue
Block a user