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
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'))
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