2012-05-18 15:18:41 +00:00
|
|
|
|
from server.people import People
|
2012-05-29 20:41:47 +00:00
|
|
|
|
from server.helpers import json_loads_from_request
|
2012-05-18 05:33:35 +00:00
|
|
|
|
|
2012-05-18 15:18:41 +00:00
|
|
|
|
__people__ = People()
|
2012-05-18 05:33:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if GET:
|
|
|
|
|
response.body = __people__.getall()
|
|
|
|
|
elif POST:
|
2012-05-29 20:41:47 +00:00
|
|
|
|
person = json_loads_from_request(request)['person']
|
2012-05-18 05:33:35 +00:00
|
|
|
|
person_id = __people__.add(person)
|
|
|
|
|
response.headers['Location'] = '/people/{}.json'.format(person_id)
|
2012-05-29 20:41:47 +00:00
|
|
|
|
person['id'] = person_id
|
|
|
|
|
response.body = person
|
|
|
|
|
response.code = 201
|
2012-05-18 05:33:35 +00:00
|
|
|
|
|
|
|
|
|
# vim:filetype=python
|