Example #1
0
def country():
    load_session()
    q = Querying()
    sources = q.get_sources(date=session['date'])['response']
    return render_template('country.html',
                           sources=sources,
                           countries=get_country_codes(),
                           **session)
Example #2
0
def index():
    if request.method == 'HEAD':
        # Just returns ack if the webserver is running
        return 'Ack'
    load_session()
    q = Querying()
    sources = q.get_sources(date=session['date'])['response']
    session.pop('asn', None)
    session.pop('country', None)
    ranks = q.asns_global_ranking(limit=100, **session)['response']
    r = [(asn, rank, q.get_asn_descriptions(int(asn))['response']) for asn, rank in ranks]
    return render_template('index.html', ranks=r, sources=sources, countries=get_country_codes(), **session)
Example #3
0
def asn_details():
    load_session()
    q = Querying()
    if 'asn' not in session:
        return redirect(url_for('/'))
    asn_descriptions = q.get_asn_descriptions(asn=session['asn'], all_descriptions=True)['response']
    sources = q.get_sources(date=session['date'])['response']
    prefix = session.pop('prefix', None)
    ranks = q.asn_details(**session)['response']
    if prefix:
        prefix_ips = q.get_prefix_ips(prefix=prefix, **session)['response']
        prefix_ips = [(ip, sorted(sources)) for ip, sources in prefix_ips.items()]
        prefix_ips.sort(key=lambda entry: len(entry[1]), reverse=True)
    else:
        prefix_ips = []
    return render_template('asn.html', sources=sources, ranks=ranks,
                           prefix_ips=prefix_ips, asn_descriptions=asn_descriptions, **session)