|
|
@@ -1,12 +1,17 @@
|
|
|
from pathlib import Path
|
|
|
from typing import Dict, List
|
|
|
from enum import Enum
|
|
|
+import json
|
|
|
|
|
|
|
|
|
class Settings:
|
|
|
- API_ImageData_prefix: str = "/api/image_data"
|
|
|
+
|
|
|
BASE_PATH = Path(__file__).parent.parent.parent.absolute()
|
|
|
|
|
|
+ CONFIG_PATH = BASE_PATH / 'Config.json'
|
|
|
+
|
|
|
+ API_ImageData_prefix: str = "/api/image_data"
|
|
|
+
|
|
|
DATA_DIR = BASE_PATH / "Data"
|
|
|
SCORE_CONFIG_PATH = BASE_PATH / "app/core/scoring_config.json"
|
|
|
|
|
|
@@ -24,6 +29,14 @@ class Settings:
|
|
|
'database': DB_NAME
|
|
|
}
|
|
|
|
|
|
+ def set_config(self):
|
|
|
+ with open(self.CONFIG_PATH, 'r') as f:
|
|
|
+ config_json = json.load(f)
|
|
|
+
|
|
|
+ self.DATABASE_CONFIG = config_json["mysql_config"]
|
|
|
+ self.DB_NAME = config_json["database_name"]
|
|
|
+ self.DB_TABLE_NAME = config_json["database_table_name"]
|
|
|
+
|
|
|
|
|
|
settings = Settings()
|
|
|
print(f"项目根目录: {settings.BASE_PATH}")
|