def search()

in text-semantic-search/semantic_search/main.py [0:0]


def search():
  try:
    query = request.args.get('query')
    show = request.args.get('show')
    show = '10' if show is None else show

    is_valid, error = validate_request(query, show)

    if not is_valid:
      results = error
    else:
      results = search_util.search(query, int(show))

  except Exception as error:
    results = 'Unexpected error: {}'.format(error)

  response = jsonify(results)
  return response