Spaces:
Running
on
Zero
Running
on
Zero
File size: 640 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 23 24 |
from typing import List
from fastapi import APIRouter, Depends
from polls import adapters
from polls.models import Question
from polls.schemas import FastQuestion, FastQuestions
router = APIRouter(prefix="/question", tags=["questions"])
@router.get("/cs", response_model=FastQuestions)
def get_questions(
questions: List[Question] = Depends(adapters.retrieve_questions),
) -> FastQuestions:
return FastQuestions.from_qs(questions)
@router.get("/{q_id}", response_model=FastQuestion)
def get_question(
question: Question = Depends(adapters.retrieve_question),
) -> FastQuestion:
return FastQuestion.from_orm(question)
|