Browse Source

turn response into JSONObject

tmdb
sipp11 10 years ago
parent
commit
5eab7d235a
  1. 24
      flasky.py

24
flasky.py

@ -71,7 +71,13 @@ def hello_world():
@crossdomain(origin='*') @crossdomain(origin='*')
def groups(): def groups():
known_groups = ['sf', 'major'] known_groups = ['sf', 'major']
r = make_response(dumps(known_groups)) json_dict = {
'meta': {
'total_count': len(known_groups)
},
'objects': known_groups
}
r = make_response(dumps(json_dict))
r.mimetype = 'application/json' r.mimetype = 'application/json'
return r return r
@ -85,7 +91,13 @@ def list_theaters(group=None):
else: else:
result = db.theater.find({'group': group}) result = db.theater.find({'group': group})
items = [i for i in result] items = [i for i in result]
r = make_response(dumps(items, default=miscObjHandler)) json_dict = {
'meta': {
'total_count': len(items)
},
'objects': items
}
r = make_response(dumps(json_dict, default=miscObjHandler))
r.mimetype = 'application/json' r.mimetype = 'application/json'
return r return r
@ -105,7 +117,13 @@ def list_showtimes(group=None, code=None):
result = db.showtimes.find(q) result = db.showtimes.find(q)
items = [i for i in result] items = [i for i in result]
r = make_response(dumps(items, default=miscObjHandler)) json_dict = {
'meta': {
'total_count': len(items)
},
'objects': items
}
r = make_response(dumps(json_dict, default=miscObjHandler))
r.mimetype = 'application/json' r.mimetype = 'application/json'
return r return r

Loading…
Cancel
Save