-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
40 lines (30 loc) · 1.01 KB
/
Copy pathconfig.py
File metadata and controls
40 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
配置文件
"""
from pydantic_settings import BaseSettings
from functools import lru_cache
class Settings(BaseSettings):
"""应用配置"""
# 数据库
DATABASE_URL: str = "sqlite+aiosqlite:///./data/whoisapi.db"
# 数据库配置(MySQL)
#DATABASE_URL: str = "mysql+aiomysql://root:123456@localhost:3306/whoisapi"
# JWT
SECRET_KEY: str = "your-secret-key-change-this-in-production"
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
# 管理员默认账户
ADMIN_USERNAME: str = "admin"
ADMIN_PASSWORD: str = "admin"
ADMIN_EMAIL: str = "admin@example.com"
# API 默认限制
DEFAULT_RATE_LIMIT: int = 100 # 每分钟请求数
DEFAULT_DAILY_LIMIT: int = 1000 # 每日请求数
# 网页查询是否需要 API Key(false 则网页可直接查询)
WEB_QUERY_REQUIRE_API_KEY: bool = False
class Config:
env_prefix = ""
extra = "allow"
@lru_cache()
def get_settings():
return Settings()