From 31550185b6632037d6be1b91ecd6d42fdeabad09 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 6 Oct 2011 00:29:37 +0530 Subject: [PATCH] json for image search working --- trubox/deals/views.py | 8 +++++++- trubox/settings.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/trubox/deals/views.py b/trubox/deals/views.py index 5f8f625..755413e 100755 --- a/trubox/deals/views.py +++ b/trubox/deals/views.py @@ -1,10 +1,16 @@ # Create your views here. from django.shortcuts import render_to_response from ox.django.shortcuts import render_to_json_response +from bingapi import bingapi +from settings import LIVE_APP_ID def index(request): return render_to_response("home.html", {}) def search(request): - d = {} + q = request.GET.get("q") + bing = bingapi.Bing(LIVE_APP_ID) + results = bing.do_image_search(q) + images = results['SearchResponse']['Image']['Results'] + d = images return render_to_json_response(d) diff --git a/trubox/settings.py b/trubox/settings.py index b0aea69..2c8f587 100755 --- a/trubox/settings.py +++ b/trubox/settings.py @@ -4,7 +4,7 @@ from os.path import join DEBUG = True TEMPLATE_DEBUG = DEBUG - +JSON_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), )