import yaml from fastapi import FastAPI from core.module import Module class MaSH: def __init__(self, config_path: str) -> None: self.server: FastAPI = FastAPI() self.config: dict = None self._load_config_(config_path) def _load_config_(self, config_path: str) -> None: try: with open(config_path, "r", encoding="UTF-8") as fp: self.config = yaml.safe_load(fp) except FileNotFoundError: raise f"Config file for MaSH server could not be opened at [{config_path}]." def add_module(self, module: Module) -> None: module.add_routes(self.server) self.server.include_router(module.get_router()) def run(self): self.server.run()