Commit 2724a773 authored by uuo00_n's avatar uuo00_n

feat(配置): 添加APP_BASE_URL配置并显示API文档链接

在配置中添加APP_BASE_URL环境变量,用于设置应用基础URL
启动时打印API文档和OpenAPI JSON的访问链接
parent cbd3da78
......@@ -10,6 +10,7 @@ class Settings(BaseSettings):
# 应用配置
APP_NAME: str = "LLM过滤系统"
API_V1_STR: str = "/api/v1"
APP_BASE_URL: str = os.getenv("APP_BASE_URL", "http://localhost:8000")
# 数据库配置
MONGODB_URL: str = os.getenv("MONGODB_URL", "mongodb://localhost:27017")
......
......@@ -59,6 +59,9 @@ app.include_router(api_router, prefix=settings.API_V1_STR)
async def startup_db_client():
await connect_to_mongo()
await sensitive_word_filter.load_sensitive_words()
base = settings.APP_BASE_URL.rstrip("/")
print(f"API 文档: {base}/docs")
print(f"OpenAPI JSON: {base}{settings.API_V1_STR}/openapi.json")
@app.on_event("shutdown")
async def shutdown_db_client():
......@@ -71,4 +74,4 @@ async def root():
"app_name": settings.APP_NAME,
"version": "1.0.0",
"message": "欢迎使用LLM过滤系统API"
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment