Пример #1
0
def index():
    if request.method == "POST":
        q = request.form['q']
        return redirect(url_for('index', q=q))

    # GET Method
    q = request.args.get('q', '').lower()
    if not q:
        return page('index.html')

    results = list(mCollAC.find({'icao': q}))

    return page('results.html', results=results,
                total_count=len(results), n=0, q=q, p=0)
Пример #2
0
def search():
    if request.method == "POST":
        n = request.form['n']
        q = request.form['q']
        return redirect(url_for('search', n=n, q=q))

    # GET request
    n = request.args.get('n', '')
    n = " ".join(re.findall("[a-zA-Z]+", n))    # security, only letters
    q = request.args.get('q', '')
    p = request.args.get('p', '')
    try:
        p = int(p)
        if p < 0:
            p = 0
    except:
        p = 0
        pass

    if n in ['regid', 'icao', 'mdl']:
        q = q.lower()

    if not q or not n:
        return redirect(url_for('index'))

    # Now, let's query
    total_count = mCollAC.find({n: {'$regex': q}}).count()

    results = list(mCollAC.find({n: {'$regex': q}}).skip(p*100).limit(100))

    return page('results.html', results=results,
                total_count=total_count, n=n, q=q, p=p)
Пример #3
0
def index():
    if request.method == "POST":
        q = request.form['q']
        return redirect(url_for('index', q=q))

    # GET Method
    q = request.args.get('q', '').lower()
    if not q:
        return page('index.html')

    results = list(mCollAC.find({'icao': q}))

    return page('results.html',
                results=results,
                total_count=len(results),
                n=0,
                q=q,
                p=0)
Пример #4
0
def search():
    if request.method == "POST":
        n = request.form['n']
        q = request.form['q']
        return redirect(url_for('search', n=n, q=q))

    # GET request
    n = request.args.get('n', '')
    n = " ".join(re.findall("[a-zA-Z]+", n))  # security, only letters
    q = request.args.get('q', '')
    p = request.args.get('p', '')
    try:
        p = int(p)
        if p < 0:
            p = 0
    except:
        p = 0
        pass

    if n in ['regid', 'icao', 'mdl']:
        q = q.lower()

    if not q or not n:
        return redirect(url_for('index'))

    # Now, let's query
    total_count = mCollAC.find({n: {'$regex': q}}).count()

    results = list(mCollAC.find({n: {'$regex': q}}).skip(p * 100).limit(100))

    return page('results.html',
                results=results,
                total_count=total_count,
                n=n,
                q=q,
                p=p)
Пример #5
0
def rand():
    count = mCollAC.find().count()
    r = random.randint(1, count)
    results = list(mCollAC.find().skip(r).limit(30))
    return page('results.html', results=results, total_count=30, p=0)
Пример #6
0
def internal_error(e):
    return page('500.html', e=e), 500
Пример #7
0
def page_not_found(e):
    return page('404.html'), 404
Пример #8
0
def stats():
    data1, data2 = statistics.treemaps()
    return page('stats.html', data1=json.dumps(data1), data2=json.dumps(data2))
Пример #9
0
def internal_error(e):
    return page('500.html', e=e), 500
Пример #10
0
def page_not_found(e):
    return page('404.html'), 404
Пример #11
0
def stats():
    data1, data2 = statistics.treemaps()
    return page('stats.html', data1=json.dumps(data1), data2=json.dumps(data2))
Пример #12
0
def data():
    return page('data.html')
Пример #13
0
def newest():
    results = list(mCollAC.find().sort('ts', -1).limit(30))
    return page('results.html', results=results, total_count=30, p=0)
Пример #14
0
def rand():
    count = mCollAC.find().count()
    r = random.randint(1, count)
    results = list(mCollAC.find().skip(r).limit(30))
    return page('results.html', results=results, total_count=30, p=0)