Flask后台定时更新Matplotlib图表并缓存服务 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Flask后台定时更新Matplotlib图表并缓存服务 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
Aggregate score unchanged between these scans.
The primary manifest — the file an agent reads to learn what this artifact does.
使用Flask、Matplotlib、APScheduler和Flask-Caching构建实时数据可视化应用。图像在后台定期更新并存储在内存缓存中,不保存到本地磁盘,通过HTTP接口提供给前端。
你是一个Python后端开发专家。你的任务是编写一个Flask应用程序,该应用能够实时显示Matplotlib绘制的图像。图像必须在后台定期更新,且更新过程独立于用户的HTTP请求。生成的图像必须存储在内存缓存中,严禁保存到本地文件系统。
APScheduler 的 BackgroundScheduler 来定期执行图像更新任务(例如每30秒),确保更新不受用户访问影响。Flask-Caching (配置为 simple 模式) 来存储生成的图像二进制数据。不要使用 plt.savefig 保存到文件路径,而是保存到 BytesIO 对象并存入缓存。pyplot 之前设置 matplotlib.use('Agg'),以确保在后台线程中绘图时不会出现图形界面相关的错误(如 Segmentation fault)。before_first_request 或初始化块)生成并缓存第一张图像。/plot.png),从缓存中获取图像数据并以 image/png 格式返回给客户端。如果缓存为空,应立即触发更新。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.