50def response(resp):
51 results = []
52
53 search_results = loads(resp.text)
54
55
56 if 'photos' not in search_results:
57 return []
58
59 if 'photo' not in search_results['photos']:
60 return []
61
62 photos = search_results['photos']['photo']
63
64
65 for photo in photos:
66 if 'url_o' in photo:
67 img_src = photo['url_o']
68 elif 'url_z' in photo:
69 img_src = photo['url_z']
70 else:
71 continue
72
73
74 if 'url_n' in photo:
75 thumbnail_src = photo['url_n']
76 elif 'url_z' in photo:
77 thumbnail_src = photo['url_z']
78 else:
79 thumbnail_src = img_src
80
81
82 results.append(
83 {
84 'url': build_flickr_url(photo['owner'], photo['id']),
85 'title': photo['title'],
86 'img_src': img_src,
87 'thumbnail_src': thumbnail_src,
88 'content': photo['description']['_content'],
89 'author': photo['ownername'],
90 'template': 'images.html',
91 }
92 )
93
94
95 return results