Add api server2
2
This commit is contained in:
38
api/models.py
Normal file
38
api/models.py
Normal 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
|
||||
Reference in New Issue
Block a user