eb4513ea创建于 2025年1月3日历史提交
import os
from dotenv import dotenv_values

CONFIG_FILE_PATH = ".env"
current_file_path = os.path.abspath(__file__)
current_dir_path = os.path.dirname(current_file_path)


class Config:
    config: dict

    def __init__(self):
        config_file = os.path.join(current_dir_path, CONFIG_FILE_PATH)
        self.config = dotenv_values(config_file)

    def __getitem__(self, key):
        if key in self.config:
            return self.config[key]
        else:
            return None


config = Config()