逐步完成前后端服务器
This commit is contained in:
96
dataServer/pressure_sensor_server.egg-info/PKG-INFO
Normal file
96
dataServer/pressure_sensor_server.egg-info/PKG-INFO
Normal file
@ -0,0 +1,96 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: pressure-sensor-server
|
||||
Version: 0.1.0
|
||||
Summary: ESP32 pressure readings receiver using Flask + SQLite
|
||||
Requires-Python: >=3.10
|
||||
Description-Content-Type: text/markdown
|
||||
Requires-Dist: flask>=3.0.0
|
||||
|
||||
# 压力数据接收服务器(Flask + SQLite, uv 管理)
|
||||
|
||||
本服务用于接收 ESP32 固件上报的压力数据,并提供增删改查接口。
|
||||
|
||||
- 语言/框架:Python 3.10+、Flask
|
||||
- 存储:SQLite(本地文件 `readings.db`)
|
||||
- 依赖管理:uv(PEP 标准 `pyproject.toml`)
|
||||
|
||||
## 快速开始(Windows PowerShell)
|
||||
|
||||
1) 安装 uv(任选一种):
|
||||
|
||||
```powershell
|
||||
irm https://astral.sh/uv/install.ps1 | iex
|
||||
```
|
||||
|
||||
或使用 pipx:
|
||||
|
||||
```powershell
|
||||
pipx install uv
|
||||
```
|
||||
|
||||
2) 安装依赖并创建虚拟环境:
|
||||
|
||||
```powershell
|
||||
cd dataServer
|
||||
uv sync
|
||||
```
|
||||
|
||||
3) 启动服务(两种方式):
|
||||
|
||||
- 方式 A:Flask 命令(可热重载)
|
||||
|
||||
```powershell
|
||||
$env:FLASK_APP = "app.py"
|
||||
uv run flask run --host 0.0.0.0 --port 5000
|
||||
```
|
||||
|
||||
- 方式 B:直接运行 Python
|
||||
|
||||
```powershell
|
||||
uv run python app.py
|
||||
```
|
||||
|
||||
> 如需我等待你手动启动服务:请直接告诉我,我会等待 30 秒再继续。
|
||||
|
||||
## 配置
|
||||
|
||||
- 环境变量:
|
||||
- `DB_PATH`:SQLite 文件路径,默认 `./readings.db`
|
||||
- `HOST`:服务监听地址(用于 `python app.py`),默认 `0.0.0.0`
|
||||
- `PORT`:服务端口(用于 `python app.py`),默认 `5000`
|
||||
|
||||
## 接口说明
|
||||
|
||||
- 健康检查:
|
||||
- `GET /health`
|
||||
|
||||
- 接收上报(供 ESP32 固件使用):
|
||||
- `POST /data`
|
||||
- JSON 示例:
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:5000/data \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"device_id":"test","timestamp":"2023-01-01T12:00:00Z","pressure":0.1,"voltage":2.5}'
|
||||
```
|
||||
|
||||
- 查询列表:
|
||||
- `GET /api/readings?device_id=<id>&start=<iso>&end=<iso>&page=1&page_size=50&sort=desc`
|
||||
|
||||
- 获取单条:
|
||||
- `GET /api/readings/<id>`
|
||||
|
||||
- 新增:
|
||||
- `POST /api/readings`(同 `/data` 体)
|
||||
|
||||
- 更新:
|
||||
- `PUT /api/readings/<id>`(可部分字段)
|
||||
|
||||
- 删除:
|
||||
- `DELETE /api/readings/<id>`
|
||||
|
||||
## 备注
|
||||
|
||||
- 时间戳接受 ISO8601,支持 `Z`(将归一化为 `+00:00`)。未提供时间戳则使用服务器当前 UTC 时间。
|
||||
- SQLite 采用 WAL 模式,适合多读少写。
|
||||
- 若需持久化到指定目录,请设置 `DB_PATH` 并确保写权限。
|
9
dataServer/pressure_sensor_server.egg-info/SOURCES.txt
Normal file
9
dataServer/pressure_sensor_server.egg-info/SOURCES.txt
Normal file
@ -0,0 +1,9 @@
|
||||
README.md
|
||||
app.py
|
||||
db.py
|
||||
pyproject.toml
|
||||
pressure_sensor_server.egg-info/PKG-INFO
|
||||
pressure_sensor_server.egg-info/SOURCES.txt
|
||||
pressure_sensor_server.egg-info/dependency_links.txt
|
||||
pressure_sensor_server.egg-info/requires.txt
|
||||
pressure_sensor_server.egg-info/top_level.txt
|
@ -0,0 +1 @@
|
||||
|
1
dataServer/pressure_sensor_server.egg-info/requires.txt
Normal file
1
dataServer/pressure_sensor_server.egg-info/requires.txt
Normal file
@ -0,0 +1 @@
|
||||
flask>=3.0.0
|
2
dataServer/pressure_sensor_server.egg-info/top_level.txt
Normal file
2
dataServer/pressure_sensor_server.egg-info/top_level.txt
Normal file
@ -0,0 +1,2 @@
|
||||
app
|
||||
db
|
Reference in New Issue
Block a user