BGP-Ranking/website/web/__init__.py

34 lines
752 B
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
2018-04-11 16:16:19 +02:00
from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap
from bgpranking.querying import Querying
app = Flask(__name__)
Bootstrap(app)
app.config['BOOTSTRAP_SERVE_LOCAL'] = True
app.debug = True
@app.route('/', methods=['GET'])
def index():
q = Querying()
ranks = q.asns_global_ranking(limit=-1)
return render_template('index.html', ranks=ranks)
2018-04-11 15:31:34 +02:00
2018-04-11 16:16:19 +02:00
@app.route('/asn', methods=['GET', 'POST'])
def asn_details():
2018-04-11 15:31:34 +02:00
q = Querying()
2018-04-11 16:16:19 +02:00
if request.method == 'POST':
asn = request.form['asn']
if request.method == 'GET':
asn = request.args['asn']
2018-04-11 15:31:34 +02:00
ranks = q.asn_details(asn)
return render_template('asn.html', asn=asn, ranks=ranks)