config.py 908 B

123456789101112131415161718192021222324252627282930313233
  1. from pathlib import Path
  2. from typing import Dict, List
  3. from enum import Enum
  4. class Settings:
  5. API_ImageData_prefix: str = "/api/image_data"
  6. BASE_PATH = Path(__file__).parent.parent.parent.absolute()
  7. DATA_DIR = BASE_PATH / "Data"
  8. SCORE_CONFIG_PATH = BASE_PATH / "app/core/scoring_config.json"
  9. # --- 数据库配置 ---
  10. DB_NAME = 'card_score_database'
  11. DB_TABLE_NAME = 'image_records'
  12. DATABASE_CONFIG: Dict[str, str] = {
  13. 'user': 'root',
  14. 'password': '123456',
  15. 'host': '127.0.0.1',
  16. }
  17. # 连接到指定数据库的配置
  18. DATABASE_CONFIG_WITH_DB: Dict[str, str] = {
  19. **DATABASE_CONFIG,
  20. 'database': DB_NAME
  21. }
  22. settings = Settings()
  23. print(f"项目根目录: {settings.BASE_PATH}")
  24. print(f"数据存储目录: {settings.DATA_DIR}")
  25. # DefectType = Enum("InferenceType", {name: name for name in settings.DEFECT_TYPE})
  26. # print()