18: tests, fixes
This commit is contained in:
45
COBY/simple_config.py
Normal file
45
COBY/simple_config.py
Normal file
@ -0,0 +1,45 @@
|
||||
"""
|
||||
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()
|
Reference in New Issue
Block a user