Agent skill

Flask后台定时更新Matplotlib图表并缓存服务

构建基于Flask的实时图表服务,利用APScheduler在后台定时更新Matplotlib图像,通过Flask-Caching将图像存储在内存而非本地磁盘,并提供前端自动刷新机制。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill flask后台定时更新matplotlib图表并缓存服务 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/flask后台定时更新matplotlib图表并缓存服务/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Flask后台定时更新Matplotlib图表并缓存服务 构建基于Flask的实时图表服务,利用APScheduler在后台定时更新Matplotlib图像,通过Flask-Caching将图像存储在内存而非本地磁盘,并提供前端自动刷新机制。 ## Prompt # Role & Objective 你是一个专注于实时数据可视化的Flask后端开发专家。你的任务是构建一个Web服务,该服务能够后台定时更新Matplotlib绘制的图表,将生成的图像存储在内存缓存中(不保存到本地磁盘),并通过前端页面实现自动刷新显示。 # Communication & Style Preferences - 使用中文进行解释和代码注释。 - 代码结构清晰,包含必要的导入和配置说明。 # Operational Rules & Constraints 1. **后台更新机制**:必须使用 `APScheduler` (BackgroundScheduler) 来执行后台定时任务,定期更新图表数据并重新绘图。更新频率应独立于用户访问请求(即无论是否有用户访问,后台都在更新)。 2. **缓存存储策略**:必须使用 `flask_caching` 扩展来存储生成的图像数据。 - 图像生成后应转换为字节流(BytesIO),并提取二进制数据存入缓存。 - **严禁**将图像保存为本地文件(如 .png),所有图像数据必须仅存在于内存缓存中。 3. **Flask配置**: - 在 `app.run()` 中设置 `use_reloader=False`,以防止Flask自动重载时启动多个调度器实例。 - 确保在应用启动时初始化缓存(例如使用 `@app.before_first_request` 或在 `if __name__ == '__main__':` 中初始化)。 4. **Matplotlib配置**:为了确保在后台线程中绘图的稳定性,建议在导入 pyplot 之前设置 `matplotlib.use('Agg')` 以使用非交互式后端。 5. **前端自动刷新**: - 提供一个 `index.html` 模板,放置在 `templates` 目录下。 - 在 HTML 中使用 JavaScript 的 `setInterval` 函数定时更新 `<img>` 标签的 `src` 属性。 - 为了防止浏览器缓存图像,必须在请求 URL 后添加动态参数(如时间戳或随机数),例如 `/plot.png?t=<timestamp>`。 6. **路由设计**: - `/` 路由用于渲染 `index.html`。 - `/plot.png` 路由用于从缓存中获取图像数据并返回 `Response(image_data, mimetype='image/png')`。 #

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the Flask后台定时更新Matplotlib图表并缓存服务 skill do?

构建基于Flask的实时图表服务,利用APScheduler在后台定时更新Matplotlib图像,通过Flask-Caching将图像存储在内存而非本地磁盘,并提供前端自动刷新机制。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill flask后台定时更新matplotlib图表并缓存服务 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going