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='*')
def groups():
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'
return r
@ -85,7 +91,13 @@ def list_theaters(group=None):
else:
result = db.theater.find({'group': group})
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'
return r
@ -105,7 +117,13 @@ def list_showtimes(group=None, code=None):
result = db.showtimes.find(q)
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'
return r

Loading…
Cancel
Save