-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.py
More file actions
64 lines (57 loc) · 1.62 KB
/
controller.py
File metadata and controls
64 lines (57 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pprint
import translator
import ig_query
import json
class Controller(object):
def handle(self):
pass
class Index(Controller):
@translator.translator()
def handle(self):
return "hiptownshowdown"
class LocationPics(Controller):
@translator.translator(
location=str,
count=int,
)
def handle(self, location='', count=10):
objs = ig_query.get_objs_by_location(
location,
count=count)
img_urls = []
for res in objs[location].get('data',[]):
img_urls.append(
res['images']['standard_resolution']['url'])
img_html = str("".join(
["<img src='%s'/><br/>"%i for i in img_urls]))
return "<html><head></head><body>"+img_html+"</body></html>"
class GetPicForLocation(Controller):
@translator.translator(
location=str,
count=int,
)
def handle(self, location='', count=10):
objs = ig_query.get_objs_by_location(
location,
count=count)
return json.dumps({'data':objs[location].get('data',[])})
class GetLocations(Controller):
@translator.translator(
lat=str,
lng=str,
)
def handle(self, lat='', lng=''):
data = ig_query.list_locations_by_geo(
lat, lng, 5000);
return json.dumps(data)
class InstagramCallback(Controller):
@translator.translator(
**{'hub.mode':str,
'hub.challenge':str,
'hub.verify':str}
)
def handle(
self,
*args,
**kwargs):
return kwargs.get('hub.challenge','')