# compute_api **Repository Path**: dufzh/compute_api ## Basic Information - **Project Name**: compute_api - **Description**: numpy接口 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-16 - **Last Updated**: 2026-03-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Compute API 一个基于 FastAPI 的计算服务 API,用于对传感器数据执行各种算法处理。 ## 项目简介 Compute API 是一个轻量级的计算服务,提供对传感器数据的在线处理能力。支持多种算法,包括移动平均、异常值移除等常用数据处理方法。 ## 功能特性 - **RESTful API 接口**:提供 `/api/compute` 端点进行数据计算 - **算法支持**: - 移动平均(Moving Average) - 异常值移除(Remove Outliers) - **动态重载**:支持通过 `/api/system/reload` 端点动态重载算法模块 - **SQLite 存储**:内置 SQLite 数据库用于数据持久化 ## 技术栈 - Python 3.x - FastAPI - 现代高性能 Web 框架 - Pydantic - 数据验证 - SQLite - 轻量级数据库 ## 快速开始 ### 安装依赖 ```bash pip install -r requirements.txt ``` ### 启动服务 ```bash python main.py ``` 服务默认运行在 `http://localhost:8000` ### API 文档 启动服务后,访问以下地址查看交互式 API 文档: - Swagger UI: `http://localhost:8000/docs` - ReDoc: `http://localhost:8000/redoc` ## API 使用示例 ### 计算端点 **请求示例:** ```bash curl -X POST "http://localhost:8000/api/compute" \ -H "Content-Type: application/json" \ -d '{ "algorithm": "moving_average", "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "params": {"window": 3} }' ``` ### 重载算法 ```bash curl -X POST "http://localhost:8000/api/system/reload" ``` ## 项目结构 ``` . ├── main.py # 主程序,包含 API 端点定义 ├── algorithms.py # 算法实现 ├── requirements.txt # Python 依赖 ├── sensor_data.csv # 传感器数据示例 ├── sim_data_linspace.py # 模拟数据生成 ├── sqlite.db # SQLite 数据库 ├── env.txt # 环境配置 └── .gitignore # Git 忽略配置 ``` ## 许可证 本项目仅供学习交流使用。