Merge branch 'main' of https://git.liulikeji.cn/xingluo/GMapiServer
This commit is contained in:
commit
df76a58370
84
README.md
Normal file
84
README.md
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
|
||||
# GMapiServer
|
||||
|
||||
**GMapiServer** 是一个基于 Python 和 Flask 构建的高性能 API 服务器,支持通过 URL 输入文件并输出下载链接,提供异步处理功能,确保主进程不被阻塞。内置缓存自动清理机制(默认保留 2 小时),支持多种工具接口调用。
|
||||
|
||||
---
|
||||
|
||||
## 🚀 项目简介
|
||||
|
||||
**GMapiServer** 是一个轻量级、模块化的 API 服务框架,旨在为开发者提供以下核心功能:
|
||||
|
||||
- **URL 输入与输出**:支持通过 URL 提交文件,返回生成文件的下载链接。
|
||||
- **异步处理**:任务在后台异步执行,不阻塞主进程,提升服务器并发性能。
|
||||
- **自动缓存清理**:内置定时清理机制,自动删除过期的缓存文件(包括输出文件),默认保留时间 2 小时。
|
||||
- **多工具接口集成**:集成 FFmpeg 和 Sanjuuni 工具接口,支持在线调用。
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 技术栈
|
||||
|
||||
- **编程语言**: Python
|
||||
- **Web 框架**: Flask
|
||||
- **异步处理**: 基于 `threading`
|
||||
- **缓存清理**: 定时任务
|
||||
- **依赖管理**: pip
|
||||
|
||||
---
|
||||
|
||||
## 🧩 支持的接口
|
||||
|
||||
### 1. FFmpeg 工具接口
|
||||
- **功能**: 在线调用 FFmpeg 工具进行视频/音频处理(如转码、裁剪、合并等)。
|
||||
- **接口文档**: [FFmpegApi 文档](https://www.liulikeji.cn/archives/FFmpegApi)
|
||||
|
||||
### 2. Sanjuuni 工具接口
|
||||
- **功能**: 在线调用 [Sanjuuni 工具](https://github.com/MCJack123/sanjuuni/tree/master)(具体功能需参考其官方文档)。
|
||||
- **接口文档**: [SanjuuniApi 文档](https://www.liulikeji.cn/archives/SanjuuniApi)
|
||||
|
||||
---
|
||||
|
||||
## 📦 部署与使用
|
||||
|
||||
### 1. 安装依赖
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 2. 启动服务器
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⏰ 自动缓存清理配置
|
||||
- **默认保留时间**: 2 小时
|
||||
- **自定义配置**:
|
||||
```python
|
||||
# 在logging_config.py文件中修改缓存清理时间
|
||||
CLEANUP_INTERVAL = 3600 # 清理临时文件的间隔(秒)
|
||||
FILE_EXPIRY = 7200 # 文件过期时间(秒)
|
||||
```
|
||||
|
||||
## 端口配置
|
||||
- **默认端口**: 5000
|
||||
- **自定义配置**:
|
||||
```python
|
||||
# 在main.py文件底部中修改
|
||||
app.run(debug=True,port=5000)
|
||||
```
|
||||
---
|
||||
|
||||
## ⚠️ 注意事项
|
||||
1. **文件合法性**: 请确保上传文件符合法律法规,不得用于非法用途。
|
||||
2. **缓存文件**: 系统会自动清理过期文件,请及时下载生成的输出文件。
|
||||
|
||||
---
|
||||
|
||||
## 📝 贡献与反馈
|
||||
欢迎提交 Issue 或 Pull Request!
|
||||
如有问题,请联系:[xingluo01@liulikeji.cn] 或 [qq:180877430]
|
||||
|
||||
---
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Flask==3.1.0
|
||||
Requests==2.32.3
|
@ -48,7 +48,7 @@ def download_file(url, temp_dir):
|
||||
|
||||
def execute_sanjuuni(input_path, output_path, sanjuuni_args):
|
||||
try:
|
||||
cmd = ['lib/sanjuuni/sanjuuni.exe', '-i', input_path] + sanjuuni_args + ['-o', output_path]
|
||||
cmd = ['lib/sanjuuni/sanjuuni', '-i', input_path] + sanjuuni_args + ['-o', output_path]
|
||||
logging.info(f"执行Sanjuuni命令: {' '.join(cmd)}")
|
||||
|
||||
result = subprocess.run(
|
||||
|
Loading…
x
Reference in New Issue
Block a user