예제 #1
0
def search_single_song():
    """
    Execute a search for a specific search term.

    Return the top 25 results.
    """
    query = request.args.get('search')

    query, artist_name, num_results, top = preprocessTerm(query)

    if request.args.get('artist_name') != "":
        artist_name = request.args.get('artist_name')
    album_name = request.args.get('album_name')
    min_rating = request.args.get('min_rating')

    songs_by_category = [(query,
                          search(query, 100, artist_name, album_name,
                                 min_rating))]

    if (num_results < len(songs_by_category[0][1])):
        results = songs_by_category[0][1][:num_results]
    else:
        results = songs_by_category[0][1]

    res = [
        (songs_by_category[0][0], results),
    ]

    #print(len(songs_by_category[0][1]))

    return render_template('index.html',
                           songs_by_category=res,
                           search_term=query,
                           artist_name=artist_name,
                           min_rating=min_rating)
예제 #2
0
def index():
    """
    Search for products across a variety of terms, and show 9 results for each.
    """
    search_terms = []

    num_results = 10
    songs_by_category = [(t, search(t, num_results)) for t in search_terms]
    return render_template(
        'index.html',
        songs_by_category=songs_by_category,
    )
예제 #3
0
def search_single_product():
    """
    Execute a search for a specific search term.

    Return the top 50 results.
    """
    query = request.args.get('search')
    num_results = 50
    products_by_category = [(query, search(query, num_results))]
    return render_template(
        'index.html',
        products_by_category=products_by_category,
        search_term=query,
    )
예제 #4
0
def search_single_song():
    """
    Execute a search for a specific search term.

    Return the top 50 results.
    """
    query = request.args.get('search')
    num_results = 50
    songs_by_category = [(query, search(query, num_results))]

    for songs in songs_by_category:
        if len(songs) == 1:
            songs[1][0] = {"title": "No Results Found"}
    return render_template(
        'index.html',
        songs_by_category=songs_by_category,
        search_term=query,
    )
예제 #5
0
def index():
    """
    Search for products across a variety of terms, and show 9 results for each.
    """
    search_terms = [
        'අම්මා',
        'සෙනෙහස',
        'හදවත',
        'ආදරේ',
        'කුවේණි'
    ]

    num_results = 9
    products_by_category = [(t, search(t, num_results)) for t in search_terms]
    return render_template(
        'index.html',
        products_by_category=products_by_category,
    )
예제 #6
0
def index():
    """
    Search for products across a variety of terms, and show 9 results for each.
    """
    search_terms = [
        'necklace',
        'metal necklace',
        'necklce',
        'OK',
        'brass necklace',
        'a brass necklace',
        'necklaces made of brass',
        "men's jacket",
    ]

    num_results = 9
    products_by_category = [(t, search(t, num_results)) for t in search_terms]
    return render_template(
        'index.html',
        products_by_category=products_by_category,
    )