39 lines
802 B
Python
39 lines
802 B
Python
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
|