Update app.py
This commit is contained in:
parent
35d299add7
commit
9d50688d27
1 changed files with 36 additions and 1 deletions
37
app.py
37
app.py
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from flask import Flask, render_template_string, jsonify, url_for, redirect, render_template, request
|
from flask import Flask, render_template_string, jsonify, url_for, redirect, render_template, request
|
||||||
|
|
||||||
|
|
@ -16,6 +17,16 @@ from modules.neighbors import parse_neighbors_data, generate_neighbors_json
|
||||||
|
|
||||||
from modules.interfaces import parse_interface_data
|
from modules.interfaces import parse_interface_data
|
||||||
|
|
||||||
|
from modules.akvorado import get_widget_data
|
||||||
|
|
||||||
|
@app.route("/ping")
|
||||||
|
def ping():
|
||||||
|
return "pong"
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def page_not_found(e):
|
||||||
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
bgp_image = os.getenv("BGP_TOOLS_IMAGE")
|
bgp_image = os.getenv("BGP_TOOLS_IMAGE")
|
||||||
|
|
@ -80,4 +91,28 @@ def bgp_route_lookup():
|
||||||
result = run_bgp_route_curl_command(ip_version, bgprouteprefix)
|
result = run_bgp_route_curl_command(ip_version, bgprouteprefix)
|
||||||
return jsonify(result)
|
return jsonify(result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/stats')
|
||||||
|
def stats_page():
|
||||||
|
return render_template("stats.html")
|
||||||
|
|
||||||
|
@app.route("/stats/src-as")
|
||||||
|
def stats_srcas_json():
|
||||||
|
return jsonify(get_widget_data("src-as"))
|
||||||
|
|
||||||
|
@app.route("/stats/src-ports")
|
||||||
|
def stats_srcport_json():
|
||||||
|
return jsonify(get_widget_data("src-port"))
|
||||||
|
|
||||||
|
@app.route("/stats/protocol")
|
||||||
|
def stats_protocol_json():
|
||||||
|
return jsonify(get_widget_data("protocol"))
|
||||||
|
|
||||||
|
@app.route("/stats/src-country")
|
||||||
|
def stats_srccountry_json():
|
||||||
|
return jsonify(get_widget_data("src-country"))
|
||||||
|
|
||||||
|
@app.route("/stats/etype")
|
||||||
|
def stats_etype_json():
|
||||||
|
return jsonify(get_widget_data("etype"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue