45 lines
878 B
Python
45 lines
878 B
Python
"""
|
|
Simple configuration for COBY system.
|
|
"""
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class APIConfig:
|
|
"""API configuration"""
|
|
host: str = "0.0.0.0"
|
|
port: int = 8080
|
|
websocket_port: int = 8081
|
|
cors_origins: list = None
|
|
rate_limit: int = 100
|
|
|
|
def __post_init__(self):
|
|
if self.cors_origins is None:
|
|
self.cors_origins = ["*"]
|
|
|
|
|
|
@dataclass
|
|
class LoggingConfig:
|
|
"""Logging configuration"""
|
|
level: str = "INFO"
|
|
file_path: str = "logs/coby.log"
|
|
|
|
|
|
@dataclass
|
|
class Config:
|
|
"""Main configuration"""
|
|
api: APIConfig = None
|
|
logging: LoggingConfig = None
|
|
debug: bool = False
|
|
|
|
def __post_init__(self):
|
|
if self.api is None:
|
|
self.api = APIConfig()
|
|
if self.logging is None:
|
|
self.logging = LoggingConfig()
|
|
|
|
|
|
# Global config instance
|
|
config = Config() |