Async release
This commit is contained in:
25
app/api/writing.py
Normal file
25
app/api/writing.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import random
|
||||
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
from fastapi import APIRouter, Path, Query, Depends
|
||||
|
||||
from app.middlewares import Authorized, IsAuthenticatedViaBearerToken
|
||||
from app.configs.constants import EducationalContent
|
||||
from app.controllers.abc import IWritingController
|
||||
|
||||
controller = "writing_controller"
|
||||
writing_router = APIRouter()
|
||||
|
||||
|
||||
@writing_router.get(
|
||||
'/{task}',
|
||||
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
||||
)
|
||||
@inject
|
||||
async def get_writing_task_general_question(
|
||||
task: int = Path(..., ge=1, le=2),
|
||||
topic: str = Query(default=random.choice(EducationalContent.MTI_TOPICS)),
|
||||
difficulty: str = Query(default=random.choice(EducationalContent.DIFFICULTIES)),
|
||||
writing_controller: IWritingController = Depends(Provide[controller])
|
||||
):
|
||||
return await writing_controller.get_writing_task_general_question(task, topic, difficulty)
|
||||
Reference in New Issue
Block a user