44def response(resp):
45 results = []
46
47 search_results = loads(resp.text)
48
49
50 for result in search_results.get('results', []):
51 href = result['url']
52 title = "" + result['name'] + " - " + result['filename']
53 repo = result['repo']
54
55 lines = {}
56 for line, code in result['lines'].items():
57 lines[int(line)] = code
58
59 code_language = code_endings.get(
60 result['filename'].split('.')[-1].lower(), result['filename'].split('.')[-1].lower()
61 )
62
63
64 results.append(
65 {
66 'url': href,
67 'title': title,
68 'content': '',
69 'repository': repo,
70 'codelines': sorted(lines.items()),
71 'code_language': code_language,
72 'template': 'code.html',
73 }
74 )
75
76
77 return results