# react-fastapi-starter **Repository Path**: Alias777/react-fastapi-starter ## Basic Information - **Project Name**: react-fastapi-starter - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-10-14 - **Last Updated**: 2026-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 列表 Demo(React + Python) 一个最小可跑的前后端分离示例:前端 React 展示一个列表,列表数据来自 Python 接口(当前写死)。 ## 目录结构 ``` . ├── backend/ # Python 后端(FastAPI) │ ├── main.py # 接口,列表数据写死在 ITEMS 里 │ └── requirements.txt └── frontend/ # React 前端(Vite) ├── index.html ├── package.json ├── vite.config.js # /api 代理到后端 8001 端口 └── src/ ├── main.jsx ├── App.jsx # 拉取并渲染列表 └── index.css ``` ## 启动后端 ```bash cd backend python -m pip install -r requirements.txt # 首次需要 uvicorn main:app --reload --port 8001 ``` 接口: - `GET http://localhost:8001/api/items` — 返回列表 - `GET http://localhost:8001/docs` — 自动生成的接口文档 ## 启动前端 ```bash cd frontend npm install # 首次需要 npm run dev ``` 浏览器打开 http://localhost:5173 即可看到列表。 > 前端通过 Vite 把 `/api` 请求代理到 `http://localhost:8001`,所以两个服务都要启动。 ## 改数据 列表数据写死在 `backend/main.py` 的 `ITEMS` 变量里,改完保存,后端 `--reload` 会自动重启生效。