예제 #1
0
def suggest(req_format='json'):
    '''
    Use the suggest package to suggest relevant resources.
    This is a non-specific route which currently does the same as
    /suggest/projects (but can change to include other suggestion types).
    
    '''
    return suggest_projects(req_format)
예제 #2
0
def suggest_projects(req_format='json'):
    '''
    Use the suggest package to suggest projects relevant to the incoming
    similar_to parameter. This is the query the user inputs into facetview
    when fundfind uses it, but can be called like any other API route with
    arbitrary similar_to values.
    '''
    # need to know what to suggest
    if not request.values.has_key('similar_to'):
        abort(400)
    else:
        from fundfind.suggest import suggest_projects
        try:
            result = suggest_projects(request.values['similar_to'])
        except ValueError as e:
            result = {'error': 'Suggestions problem. Could not encode suggestions in JSON to send to front-end.'}
        return jsonify(result)