749 B
749 B
Python 后端服务器
使用 FastAPI 开发,依赖和虚拟环境统一由 uv 管理。
开发
uv sync
uv run uvicorn backend_server.main:app --reload --host 127.0.0.1 --port 8000
- 健康检查:
http://localhost:8000/health - API 文档:
http://localhost:8000/docs - OpenAPI:
http://localhost:8000/openapi.json
默认允许来自 http://localhost:3000、http://localhost:5173 的浏览器请求。
通过环境变量配置逗号分隔的允许来源:
CORS_ORIGINS=https://your-frontend.example uv run uvicorn backend_server.main:app
检查
uv run pytest
uv run ruff check .
uv run ruff format --check .
提交 uv.lock,在其他电脑使用 uv sync --locked 复现依赖。