def searchRedirect(request, tags='', num=1, nsid=''): if not num or not num.isdigit() or int(num) <= 0: num = 1 resp = HttpResponse(status=302) nsid = getUserNSID(request, resp, apiKey, nsid) photo = flickrapi.getPhotoBySearch(apiKey, nsid, tags, num) destinationUrl = flickrapi.getPhotoPageUrl(photo, nsid) resp['Title'] = photo.title.encode("utf-8") resp['Location'] = destinationUrl return resp
def searchImage(request, tags='', num=1, size='', nsid='' ): if not num or not num.isdigit() or int(num) <= 0: num = 1 if not size: size = 's' resp = HttpResponse(status=302) nsid = getUserNSID(request, resp, apiKey, nsid) photo = flickrapi.getPhotoBySearch(apiKey, nsid, tags, num) destinationUrl = flickrapi.getImageUrl(photo, size) resp['Cache-Control'] = "private, max-age=3600" resp['Title'] = photo.title.encode("utf-8") resp['Location'] = destinationUrl return resp