15 lines
485 B
Python
15 lines
485 B
Python
from fastapi import APIRouter, Depends
|
|
from typing import List
|
|
from sqlalchemy.orm import Session
|
|
from core.database import get_db
|
|
from schemas.apple import AppleSchema
|
|
from helpers.apple_helpers import get_apple_by_name
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/rest", status_code=200, response_model=List[AppleSchema])
|
|
async def get_apples_by_name(name: str, db: Session = Depends(get_db)):
|
|
apples = get_apple_by_name(db, name)
|
|
if not apples:
|
|
return []
|
|
return [apples] |