Add api server2

2
This commit is contained in:
2026-02-08 20:48:59 +01:00
parent 627a730191
commit 5a2fdd65d0
14 changed files with 328 additions and 0 deletions

38
api/models.py Normal file
View File

@@ -0,0 +1,38 @@
from enum import Enum
from typing import Any
from pydantic import BaseModel, Field
from api.config import ALLOWED_MODES, MAX_RESOLUTION, MIN_RESOLUTION
class ScanMode(str, Enum):
lineart = "Lineart"
halftone = "Halftone"
gray = "Gray"
color = "Color"
class ScanRequest(BaseModel):
mode: ScanMode = ScanMode.lineart
resolution: int = Field(default=400, ge=MIN_RESOLUTION, le=MAX_RESOLUTION)
language: str = "deu"
output: str | None = None
class ScanResponse(BaseModel):
message: str
output: str
mode: str
resolution: int
class StatusResponse(BaseModel):
scanning: bool
last_result: dict[str, Any] | None = None
current: dict[str, str] | None = None
class PaperResponse(BaseModel):
paper_loaded: bool
raw: str | None = None