Beispiel #1
0
def add_to_index(keyword, url):
    entry = col.find_one({'keyword': keyword})
    if entry:
        if not url in entry['url']:
            entry['url'].append(url)
            col.save(entry)
        return
    # not found, add new keyword to index
    col.insert({'keyword': keyword, 'url': [url]})
def index():
    if request.method == 'POST':
        keyword = request.form['keyword']
        if keyword:
            return render_template(
                'index.html',
                query=col.find_one({'keyword': keyword}),
                keyword=keyword)
    return render_template('index.html')