Esempio n. 1
0
def apisearch():
    "Perform a search, returning JSON"
    params = get_search_params()
    if 'error' in params:
        response = Response(json.dumps({'code': 400, 'error': params['error']}), 400, mimetype="application/json")
    else:
        response = Response(json.dumps({'code': 200, 'result': params.get('data'), 'mapping': params.get('mapping')}), 200, mimetype="application/json")
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response
Esempio n. 2
0
def search():
    params = get_search_params()
    if 'error' in params and params['error'] != 'You must provide a query.':
        flash(params["error"])
    return render_template('search.html',
                           query=params.get('query'),
                           data=params.get('data'),
                           mapping=params.get('mapping'),
                           start_from=params.get('start_from'),
                           page_size=params.get('page_size'))
Esempio n. 3
0
def apisearch():
    "Perform a search, returning JSON"
    params = get_search_params()
    if 'error' in params:
        response = Response(json.dumps({
            'code': 400,
            'error': params['error']
        }),
                            400,
                            mimetype="application/json")
    else:
        response = Response(json.dumps({
            'code': 200,
            'result': params.get('data'),
            'mapping': params.get('mapping')
        }),
                            200,
                            mimetype="application/json")
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response
Esempio n. 4
0
def search():
    params = get_search_params()
    if 'error' in params and params['error'] != 'You must provide a query.':
        flash(params["error"])
    return render_template('search.html', query=params.get('query'), data=params.get('data'), mapping=params.get('mapping'), start_from=params.get('start_from'), page_size=params.get('page_size'))