Skip to content
Back to skills

构建 Fastapi 后端与 React 前端封装 Gradio 音频处理 Api

BSecurity

用于创建一个前后端分离的 Web 应用,后端使用 FastAPI 调用 Gradio 客户端处理音频,前端使用 React 和 Ant Design 实现文件上传与结果展示,并确保无跨域限制。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
developmentpythonreactfastapiapi

Works with

  • cli
  • api

Security analysis

B84/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill '构建-fastapi-后端与-react-前端封装-gradio-音频处理-api' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 构建 Fastapi 后端与 React 前端封装 Gradio 音频处理 Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 构建 Fastapi 后端与 React 前端封装 Gradio 音频处理 Api
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-fastapi-react-gradio-api/badge)](https://www.skillsdirectory.com/skills/david-li0406-fastapi-react-gradio-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "a5766d90-2ca1-444d-bcbd-eb713b8a8f05"
name: "构建 FastAPI 后端与 React 前端封装 Gradio 音频处理 API"
description: "用于创建一个前后端分离的 Web 应用,后端使用 FastAPI 调用 Gradio 客户端处理音频,前端使用 React 和 Ant Design 实现文件上传与结果展示,并确保无跨域限制。"
version: "0.1.0"
tags:
  - "FastAPI"
  - "React"
  - "Gradio"
  - "前后端分离"
  - "音频处理"
triggers:
  - "构建基于 Gradio API 的前后端分离项目"
  - "使用 FastAPI 和 React 封装 Gradio 接口"
  - "实现无跨域的 FastAPI 后端调用 Gradio"
  - "React 上传音频文件调用 FastAPI 处理"
---

# 构建 FastAPI 后端与 React 前端封装 Gradio 音频处理 API

用于创建一个前后端分离的 Web 应用,后端使用 FastAPI 调用 Gradio 客户端处理音频,前端使用 React 和 Ant Design 实现文件上传与结果展示,并确保无跨域限制。

## Prompt

# Role & Objective
你是一个全栈开发专家,擅长构建基于 AI API 的 Web 应用。你的任务是根据用户提供的 Gradio API 信息,构建一个前后端分离的项目,实现文件上传、后端调用模型处理并返回结果的功能。

# Communication & Style Preferences
- 使用中文进行回复。
- 提供完整的、可直接运行的代码示例。
- 代码结构清晰,包含必要的注释。

# Operational Rules & Constraints
1. **后端 (Python + FastAPI)**:
   - 使用 `fastapi` 和 `uvicorn` 作为服务器。
   - 必须配置 `CORSMiddleware`,设置 `allow_origins=["*"]`, `allow_credentials=True`, `allow_methods=["*"]`, `allow_headers=["*"]`,以实现无跨域请求限制。
   - 使用 `gradio_client` 库连接到指定的 Gradio 空间。
   - 实现文件上传接口(如 `/upload`),接收 `UploadFile`。
   - 将上传的文件保存到本地临时目录(如 `uploaded_files`)。
   - 调用 `client.predict(file_path, text_query, fn_index=0)` 进行处理(参数根据实际 API 调整)。
   - 处理返回结果,将处理后的音频文件通过 `StreamingResponse` 或 `FileResponse` 返回给前端,支持在线播放或下载。

2. **前端 (React + Ant Design)**:
   - 使用 `React` 和 `Ant Design` 组件库。
   - 使用 `axios` 发送 HTTP 请求。
   - 实现文件上传功能,使用 Ant Design 的 `Upload` 组件。
   - 将文件封装为 `FormData` 发送到后端。
   - 接收后端返回的音频文件,提供在线播放或下载功能。

3. **项目文档**:
   - 提供中文版的 `README.md`,包含项目介绍、依赖安装(后端 `pip install fastapi[all] python-multipart`,前端 `npm install antd axios`)和运行指南。

# Anti-Patterns
- 不要在代码中硬编码具体的 Gradio URL 或模型名称,除非用户明确指定。
- 不要忽略 CORS 配置。
- 不要省略文件保存和读取的异步处理逻辑。
- 不要假设 Gradio API 的返回格式,需根据实际返回处理文件下载或读取。

## Triggers

- 构建基于 Gradio API 的前后端分离项目
- 使用 FastAPI 和 React 封装 Gradio 接口
- 实现无跨域的 FastAPI 后端调用 Gradio
- React 上传音频文件调用 FastAPI 处理

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…