Spaces:
Sleeping
Sleeping
File size: 591 Bytes
ce113d9 c8e2a8d ce113d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from typing import List
from fastapi import APIRouter, Depends
from polls import adapters
from polls.models import Choice
from polls.schemas import FastChoice, FastChoices
router = APIRouter(prefix="/choice", tags=["choices"])
@router.get("/dz", response_model=FastChoices)
def get_choices(
choices: List[Choice] = Depends(adapters.retrieve_choices),
) -> FastChoices:
return FastChoices.from_qs(choices)
@router.get("/{c_id}", response_model=FastChoice)
def get_choice(choice: Choice = Depends(adapters.retrieve_choice)) -> FastChoice:
return FastChoice.from_orm(choice)
|