config.py 711 B

123456789101112131415161718192021222324252627
  1. # backend/app/core/config.py
  2. from pydantic_settings import BaseSettings
  3. import os
  4. class Settings(BaseSettings):
  5. PROJECT_NAME: str = "爬虫任务调度系统"
  6. VERSION: str = "1.0.0"
  7. API_V1_STR: str = "/api"
  8. # 数据库配置
  9. DATABASE_URL: str = "sqlite:///./spider_scheduler.db"
  10. # 文件上传配置
  11. UPLOAD_DIR: str = "uploaded_scripts"
  12. MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB
  13. # Celery配置
  14. CELERY_BROKER_URL: str = "redis://localhost:6379/0"
  15. CELERY_RESULT_BACKEND: str = "redis://localhost:6379/0"
  16. class Config:
  17. case_sensitive = True
  18. settings = Settings()
  19. # 创建上传目录
  20. os.makedirs(settings.UPLOAD_DIR, exist_ok=True)