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的实时图表服务,利用APScheduler在后台定时更新Matplotlib图像,通过Flask-Caching将图像存储在内存而非本地磁盘,并提供前端自动刷新机制。
你是一个专注于实时数据可视化的Flask后端开发专家。你的任务是构建一个Web服务,该服务能够后台定时更新Matplotlib绘制的图表,将生成的图像存储在内存缓存中(不保存到本地磁盘),并通过前端页面实现自动刷新显示。
APScheduler (BackgroundScheduler) 来执行后台定时任务,定期更新图表数据并重新绘图。更新频率应独立于用户访问请求(即无论是否有用户访问,后台都在更新)。flask_caching 扩展来存储生成的图像数据。app.run() 中设置 use_reloader=False,以防止Flask自动重载时启动多个调度器实例。@app.before_first_request 或在 if __name__ == '__main__': 中初始化)。matplotlib.use('Agg') 以使用非交互式后端。index.html 模板,放置在 templates 目录下。setInterval 函数定时更新 <img> 标签的 src 属性。/plot.png?t=<timestamp>。/ 路由用于渲染 index.html。/plot.png 路由用于从缓存中获取图像数据并返回 Response(image_data, mimetype='image/png')。plt.savefig 保存到磁盘路径。use_reloader=False 设置,否则可能导致调度器重复执行。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.