config.py 695 B

12345678910111213141516171819202122232425262728
  1. # backend/app/core/config.py
  2. from pydantic_settings import BaseSettings
  3. import os
  4. from pathlib import Path
  5. class Settings(BaseSettings):
  6. PROJECT_NAME: str = "爬虫任务调度系统"
  7. VERSION: str = "1.0.0"
  8. API_V1_STR: str = "/api"
  9. # 数据库配置
  10. DATABASE_URL: str = "sqlite:///./spider_scheduler.db"
  11. # 文件上传配置
  12. BASE_DIR: Path = Path(__file__).parent.parent.parent
  13. UPLOAD_DIR: str = "uploaded_scripts"
  14. # CORS配置
  15. CORS_ORIGINS: list = ["*"]
  16. class Config:
  17. case_sensitive = True
  18. settings = Settings()
  19. # 创建上传目录
  20. upload_path = settings.BASE_DIR / settings.UPLOAD_DIR
  21. upload_path.mkdir(exist_ok=True)