v1.0.0提交
This commit is contained in:
69
backend/config.py
Normal file
69
backend/config.py
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
PerToolBox Server - 配置模块
|
||||
Copyright (C) 2024 Sea Network Technology Studio
|
||||
Author: Canglan <admin@sea-studio.top>
|
||||
License: AGPL v3
|
||||
"""
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from typing import List, Optional
|
||||
|
||||
class Settings(BaseSettings):
|
||||
# 应用配置
|
||||
APP_NAME: str = "PerToolBox"
|
||||
DEBUG: bool = False
|
||||
ENVIRONMENT: str = "production"
|
||||
SECRET_KEY: str
|
||||
|
||||
# 数据库
|
||||
DB_HOST: str = "localhost"
|
||||
DB_PORT: int = 3306
|
||||
DB_USER: str
|
||||
DB_PASSWORD: str
|
||||
DB_NAME: str
|
||||
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
return f"mysql+pymysql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}?charset=utf8mb4"
|
||||
|
||||
# Redis
|
||||
REDIS_HOST: str = "localhost"
|
||||
REDIS_PORT: int = 6379
|
||||
REDIS_PASSWORD: Optional[str] = None
|
||||
REDIS_DB: int = 0
|
||||
|
||||
# 限流
|
||||
RATE_LIMIT_ENABLED: bool = True
|
||||
RATE_LIMIT_REQUESTS: int = 100
|
||||
RATE_LIMIT_PERIOD: int = 60
|
||||
|
||||
# CORS
|
||||
ALLOWED_ORIGINS: List[str] = []
|
||||
|
||||
# 阿里云短信
|
||||
ALIYUN_SMS_ACCESS_KEY_ID: Optional[str] = None
|
||||
ALIYUN_SMS_ACCESS_KEY_SECRET: Optional[str] = None
|
||||
ALIYUN_SMS_SIGN_NAME: Optional[str] = None
|
||||
ALIYUN_SMS_TEMPLATE_CODE: Optional[str] = None
|
||||
|
||||
# 腾讯企业邮
|
||||
SMTP_HOST: str = "smtp.exmail.qq.com"
|
||||
SMTP_PORT: int = 465
|
||||
SMTP_USER: Optional[str] = None
|
||||
SMTP_PASSWORD: Optional[str] = None
|
||||
SMTP_FROM: Optional[str] = None
|
||||
|
||||
# 微信公众号(预留)
|
||||
WECHAT_APPID: Optional[str] = None
|
||||
WECHAT_APPSECRET: Optional[str] = None
|
||||
WECHAT_TOKEN: Optional[str] = None
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
case_sensitive=True
|
||||
)
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user