Esempio n. 1
0
def getdirectory(uuid):
    print("You are getting insert directory request")
    content = request.json
    json_result = search.get_directory_path(postgres)
    json_object = JFY({"items": json_result})
    print("response for get_directory_path = ", json_object.get_json())
    return json_object
Esempio n. 2
0
def query(uuid):
    # global q2emb
    if request.method == 'POST':
        content = request.json
        print("search string = ", content['todo_description'])
        print("You are getting search request")
        search_string = content['todo_description']
        # json_dump = jsonify({"uuid": uuid})
        # json_object = json_response({})
        json_object = JFY({})
        resultset = None
        if search.q2emb != None:
            json_result = search.search_query(postgres, search_string, 10)
            # json_result = json.dumps(json_result)
            json_object = JFY({"items": json_result})
            print("json_results = ", json_object)

        else:
            print("Search Engine is not Valid")
        # jsonStr = json_response(json_object)
        # return jsonify(Results=jsonStr)
        print("response = ", json_object.get_json())
        return json_object
    else:
        print("may be a GET request")
        return "may be a GET request"
Esempio n. 3
0
def handle_all_errors(error):
    try:
        response = JSON(error=error.to_dict().get('__all__'))
    except Exception:
        response = JSON(error=str(error))

    response.status_code = 500
    return response
Esempio n. 4
0
def getdirectorybyid(uuid):
    print("You are getting get directory by id request")
    content = request.json
    directoryid = content
    print("directoryid = ", directoryid)
    json_result = search.get_directory_path_byid(postgres, directoryid)
    json_object = JFY({"item": json_result})
    print("json_results = ", json_object)
    print("response for get_directory_path_byid = ", json_object.get_json())
    return json_object
Esempio n. 5
0
def results(uuid):
    if request.method == 'POST':
        print("You are getting results request")
        json_result = search.get_results(postgres)
        json_object = JFY({"items": json_result})
        print("json_results = ", json_object)
        print("response = ", json_object.get_json())
        return json_object
    else:
        print("may be a GET request")
        return "may be a GET request"
Esempio n. 6
0
def getmanualtag(uuid):
    if request.method == 'POST':
        print("You are getting getmanualtag request")
        content = request.json
        print("paragraph id = ", content)
        json_object = JFY({})
        json_result = search.get_manualtag(postgres, content)
        json_object = JFY({"item": json_result})
        print("json_results = ", json_object)
        print("response = ", json_object.get_json())
        return json_object
    else:
        print("may be a GET request")
        return "may be a GET request"
Esempio n. 7
0
def updatemanualtag(uuid):
    if request.method == 'POST':
        print("You are getting updatemanualtag request")
        content = request.json
        manualtag = content['manual_tag']
        paraid = content['paraid']
        print("update input = ", content)
        print("manualtag input = ", manualtag)
        print("paraid input = ", paraid)
        json_object = JFY({})
        json_result = search.update_manualtag(postgres, paraid, manualtag)
        json_object = JFY({"updatedrows": json_result})
        print("json_results = ", json_object)
        print("response = ", json_object.get_json())
        return json_object
    else:
        print("may be a GET request")
        return "may be a GET request"
Esempio n. 8
0
def page_not_found(error):
    response = JSON(error=str(app.config['ERRORS']['404']))
    response.status_code = 404
    return response
Esempio n. 9
0
def unauthorized(error):
    response = JSON(error=str(app.config['ERRORS']['401']))
    response.status_code = 401
    return response
Esempio n. 10
0
def bad_request(error):
    response = JSON(error=str(app.config['ERRORS']['400']))
    response.status_code = 400
    return response
Esempio n. 11
0
def service_unavailable_error(error):
    response = JSON(error=str(app.config['ERRORS']['503']))
    response.status_code = 503
    return response
Esempio n. 12
0
def internal_server_error(error):
    response = JSON(error=str(app.config['ERRORS']['500']))
    response.status_code = 500
    return response
Esempio n. 13
0
def handle_invalid_request(error):
    response = JSON(error.to_dict())
    response.status_code = error.status_code
    return response