Exemplo n.º 1
0
def do_search():

    if request.method == 'POST':
        req = request.values
    else:
        req = request.args
    terms = req.get("terms")
    return jsonify(search.do_search(terms))
Exemplo n.º 2
0
async def do_search_api(query_text: str):
    try:
        conn, cursor = init_conn()
        bc = init_bc_client()
        results = do_search(query_text, index_client, conn, cursor, bc)
        return results
    except Exception as e:
        return "{0}".format(e)
    finally:
        cursor.close()
        conn.close()
        bc.close()
Exemplo n.º 3
0
async def do_search_api(query_text: Item):
    try:
        conn, cursor = init_conn()
        bc = init_bc_client()
        # print(1111)
        # print(query_text)
        # print("======",query_text.abstract,"=====")
        print(type(query_text.abstract))
        results = do_search(query_text.abstract,index_client,conn,cursor,bc)
        return results
    except Exception as e:
       return "{0}".format(e), 400
    finally:
        cursor.close()
        conn.close()
        bc.close()
Exemplo n.º 4
0
async def do_search_api(image: UploadFile=File(...)):
	try:
		contents = await image.read()
		image_name = image.filename
		image_path = im_path + str(image_name)
		print(image_name)
		# print(image_path)
		with open(image_path,'wb') as f:
			f.write(contents)		
		conn, cursor = init_conn()
		results = do_search(image_path,index_client,conn,cursor,model, device)
		return results
	except Exception as e:
		return "{0}".format(e)
	finally:
		cursor.close()
		conn.close()