2024-12-15 14:40:03 +01:00
|
|
|
"""Server Module."""
|
|
|
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from pydantic import Field, IPvAnyAddress, field_validator
|
|
|
|
|
|
|
|
from akkudoktoreos.config.configabc import SettingsBaseModel
|
2025-01-05 14:41:07 +01:00
|
|
|
from akkudoktoreos.core.logging import get_logger
|
2024-12-15 14:40:03 +01:00
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class ServerCommonSettings(SettingsBaseModel):
|
|
|
|
"""Common server settings.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
To be added
|
|
|
|
"""
|
|
|
|
|
|
|
|
server_fastapi_host: Optional[IPvAnyAddress] = Field(
|
|
|
|
default="0.0.0.0", description="FastAPI server IP address."
|
|
|
|
)
|
|
|
|
server_fastapi_port: Optional[int] = Field(
|
|
|
|
default=8503, description="FastAPI server IP port number."
|
|
|
|
)
|
2024-12-19 14:45:20 +01:00
|
|
|
server_fastapi_verbose: Optional[bool] = Field(default=False, description="Enable debug output")
|
2024-12-29 18:42:49 +01:00
|
|
|
server_fastapi_startup_server_fasthtml: Optional[bool] = Field(
|
|
|
|
default=True, description="FastAPI server to startup application FastHTML server."
|
|
|
|
)
|
2024-12-15 14:40:03 +01:00
|
|
|
server_fasthtml_host: Optional[IPvAnyAddress] = Field(
|
|
|
|
default="0.0.0.0", description="FastHTML server IP address."
|
|
|
|
)
|
|
|
|
server_fasthtml_port: Optional[int] = Field(
|
|
|
|
default=8504, description="FastHTML server IP port number."
|
|
|
|
)
|
|
|
|
|
|
|
|
@field_validator("server_fastapi_port", "server_fasthtml_port")
|
|
|
|
def validate_server_port(cls, value: Optional[int]) -> Optional[int]:
|
|
|
|
if value is not None and not (1024 <= value <= 49151):
|
|
|
|
raise ValueError("Server port number must be between 1024 and 49151.")
|
|
|
|
return value
|