Add GET endpoint for countries
This commit is contained in:
parent
f81f5f8cf3
commit
6a9358ca49
16
endpoints/countries.get.py
Normal file
16
endpoints/countries.get.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Entity: Country
|
||||
from fastapi import APIRouter, Depends, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from app.api.db.database import get_db
|
||||
from app.api.models.country import Country
|
||||
from app.api.schemas.country import CountrySchema
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/countries", status_code=200, response_model=List[CountrySchema])
|
||||
async def get_countries(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
countries = db.query(Country).all()
|
||||
return countries
|
Loading…
x
Reference in New Issue
Block a user