重构现代化 FastAPI 后端项目框架

This commit is contained in:
2026-01-21 16:50:57 +08:00
parent 9e06e68a15
commit c56f2fd1db
352 changed files with 176 additions and 70 deletions

18
scripts/run_server.py Normal file
View File

@@ -0,0 +1,18 @@
import asyncio
import sys
import uvicorn
if __name__ == "__main__":
# Windows 设置事件循环策略
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
# 用 uvicorn.run 支持 workers 参数
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=8000,
workers=2, # 这里可以设置多进程
loop="asyncio",
)