A Python port of the Invisible Internet Project (I2P)
at main 32 lines 894 B view raw
1"""Graphs routes — interactive charts via Plotly.js. 2 3Replaces Java I2P's JRobin server-side PNG rendering with 4client-side interactive charts. 5 6Ported from net.i2p.router.web.helpers.GraphHelper / SummaryListener. 7""" 8 9from __future__ import annotations 10 11from flask import Blueprint, render_template, current_app, jsonify 12 13bp = Blueprint("graphs", __name__) 14 15 16@bp.route("/graphs") 17def graphs(): 18 """Graphs overview page with Plotly.js charts.""" 19 return render_template("graphs.html") 20 21 22@bp.route("/graphs/data/<stat_name>") 23def graph_data(stat_name: str): 24 """JSON endpoint for chart data.""" 25 stats = current_app.config.get("STATS_COLLECTOR") 26 if stats is None: 27 return jsonify({"labels": [], "values": []}) 28 samples = stats.get(stat_name) 29 return jsonify({ 30 "labels": [s.timestamp for s in samples], 31 "values": [s.value for s in samples], 32 })