Exemple #1
0
def get_results(search_term):
    values = parse_terms(search_term)
    terms = values['terms']
    hasAnd = values['hasAnd']
    hasOr = values['hasOr']
    results = perform_database_search(terms, hasOr, hasAnd)
    data = []
    count = 1
    for result in results:
        res_str = str(result)
        if len(res_str) > 0:
            temp = {str('Result ' + str(count)): str(result)}
            data.append(temp)
            count += 1
    return jsonify({'Search_Results': data})
Exemple #2
0
def get_results(search_term):
	values = parse_terms(search_term)
	terms = values['terms']
	hasAnd = values['hasAnd']
	hasOr = values['hasOr']
	results = perform_database_search(terms, hasOr, hasAnd)
	data = []
	count = 1
	for result in results:
		res_str = str(result)
		if len(res_str) > 0:
			temp = { str('Result ' + str(count)): str(result) }
			data.append(temp)
			count += 1
	return jsonify({'Search_Results' : data})
Exemple #3
0
def search_app(environ, start_response):
    #print("ENVIRON:", environ)
    message = ""
    status = '200 OK'
    headers = [('Content-type', 'html; charset=utf-8')]
    start_response(status, headers)
    if (environ['REQUEST_METHOD'] == 'POST'):
        message += "<br>Your data has been recorded:"
        request_body_size = int(environ['CONTENT_LENGTH'])
        request_body = environ['wsgi.input'].read(request_body_size)
        form_vals = get_form_vals(request_body)

        if len(form_vals) > 0:
            word = ""
            res = ""
            for item in form_vals.keys():
                message += "<br/>" + item + " = " + form_vals[item]
                if item == "word":
                    word = form_vals[item]
                elif item == "results":
                    res = form_vals[item]

            values = parse_terms(word)
            terms = values['terms']
            hasAnd = values['hasAnd']
            hasOr = values['hasOr']

            message += "<br><h3>Search Results for '" + word + "':</h3><br>"
            results = perform_database_search(terms, hasOr, hasAnd)
            for result in results:
                message += "<p>" + str(result) + "</p>"

    message += "<h1>Search!</h1>"
    message += "<form method='POST'><br>Search Word:<input type=text name='word'>"
    message += "<br><br><input type='submit' name='Submit' ></form>"
    return [bytes(message, 'utf-8')]
Exemple #4
0
def search_app(environ, start_response):
	#print("ENVIRON:", environ)
	message=""
	status = '200 OK'
	headers = [('Content-type', 'html; charset=utf-8')]
	start_response(status, headers)
	if(environ['REQUEST_METHOD'] == 'POST'):
		message += "<br>Your data has been recorded:"
		request_body_size = int(environ['CONTENT_LENGTH'])
		request_body = environ['wsgi.input'].read(request_body_size)
		form_vals = get_form_vals(request_body)
		
		if len(form_vals) > 0:
			word = ""
			res = ""
			for item in form_vals.keys():
				message += "<br/>" + item + " = " + form_vals[item]
				if item == "word":
					word = form_vals[item]
				elif item == "results":
					res = form_vals[item]

			values = parse_terms(word)
			terms = values['terms']
			hasAnd = values['hasAnd']
			hasOr = values['hasOr']
			
			message += "<br><h3>Search Results for '" + word + "':</h3><br>"
			results = perform_database_search(terms, hasOr, hasAnd)
			for result in results:
				message += "<p>" + str(result) + "</p>"

	message += "<h1>Search!</h1>"
	message += "<form method='POST'><br>Search Word:<input type=text name='word'>"
	message += "<br><br><input type='submit' name='Submit' ></form>"
	return[bytes(message,'utf-8')]