feat: create structure for the project and first problem
This commit is contained in:
4
app/routers/__init__.py
Normal file
4
app/routers/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from app.routers.math import router as api_router
|
||||
|
||||
|
||||
__all__ = ["api_router"]
|
||||
32
app/routers/grade_1.py
Normal file
32
app/routers/grade_1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.problems.grade_1.join_pictures_with_quantity import (
|
||||
join_pictures_with_quantity,
|
||||
)
|
||||
from app.schemas.grade_1.join_pictures_with_quantity import (
|
||||
JoinPicturesWithQuantityProblem,
|
||||
JoinPicturesWithQuantityRequest,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/grade_1", tags=["Grade 1"])
|
||||
|
||||
|
||||
@router.post(
|
||||
"/join_pictures_with_quantity",
|
||||
response_model=JoinPicturesWithQuantityProblem,
|
||||
)
|
||||
def create_join_pictures_with_quantity_problem(
|
||||
request: JoinPicturesWithQuantityRequest,
|
||||
) -> dict:
|
||||
try:
|
||||
return join_pictures_with_quantity(
|
||||
available_pictures=[
|
||||
picture.model_dump() for picture in request.available_pictures
|
||||
],
|
||||
container_count_per_side=request.container_count_per_side,
|
||||
min_quantity=request.min_quantity,
|
||||
max_quantity=request.max_quantity,
|
||||
seed=request.seed,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
7
app/routers/math.py
Normal file
7
app/routers/math.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.routers import grade_1
|
||||
|
||||
|
||||
router = APIRouter(prefix="/math")
|
||||
router.include_router(grade_1.router)
|
||||
Reference in New Issue
Block a user