AI 生成: 一个基于 Python Flask 的车辆管理系统,提供车辆的增删改查、搜索和统计功能。

This commit is contained in:
admin
2026-09-29 18:07:16 +08:00
commit 798550e1f3
8 changed files with 678 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
# 车辆管理系统 (Vehicle Management System)
一个基于 Python Flask 的轻量级车辆管理系统,提供车辆的增删改查、搜索和统计功能。
## 功能特性
- ✅ 车辆列表展示
- ✅ 添加新车辆
- ✅ 编辑车辆信息
- ✅ 删除车辆
- ✅ 按车牌/品牌/型号搜索
- ✅ 车辆统计(总数、按状态统计)
- ✅ 数据持久化(SQLite)
## 技术栈
- 后端:Python 3.8+ / Flask
- 数据库:SQLite
- 前端:HTML / CSS / JavaScript
## 目录结构
```
vehicle-management-system/
├── app.py # Flask 应用入口
├── models.py # 数据模型
├── requirements.txt # 依赖列表
├── README.md # 项目说明
├── static/
│ ├── style.css # 样式文件
│ └── script.js # 前端脚本
└── templates/
├── index.html # 首页(车辆列表)
└── edit.html # 编辑页面
```
## 快速开始
### 1. 安装依赖
```bash
pip install -r requirements.txt
```
### 2. 启动应用
```bash
python app.py
```
### 3. 访问
打开浏览器访问:http://127.0.0.1:5000
## API 接口
| 方法 | 路径 | 说明 |
|--------|-----------------------|--------------------|
| GET | / | 首页(车辆列表) |
| GET | /api/vehicles | 获取所有车辆 |
| POST | /api/vehicles | 添加车辆 |
| GET | /api/vehicles/<id> | 获取单个车辆 |
| PUT | /api/vehicles/<id> | 更新车辆 |
| DELETE | /api/vehicles/<id> | 删除车辆 |
| GET | /api/stats | 获取统计数据 |
## 车辆字段
- `plate`:车牌号(唯一)
- `brand`:品牌
- `model`:型号
- `year`:年份
- `color`:颜色
- `status`:状态(available / in_use / maintenance)
- `owner`:车主
## License
MIT