json for image search working
This commit is contained in:
parent
af030d92d7
commit
31550185b6
|
@ -1,10 +1,16 @@
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from ox.django.shortcuts import render_to_json_response
|
from ox.django.shortcuts import render_to_json_response
|
||||||
|
from bingapi import bingapi
|
||||||
|
from settings import LIVE_APP_ID
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return render_to_response("home.html", {})
|
return render_to_response("home.html", {})
|
||||||
|
|
||||||
def search(request):
|
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)
|
return render_to_json_response(d)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from os.path import join
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
JSON_DEBUG = DEBUG
|
||||||
ADMINS = (
|
ADMINS = (
|
||||||
# ('Your Name', 'your_email@domain.com'),
|
# ('Your Name', 'your_email@domain.com'),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user