Using aspen instead of homespun wsgi thingy

This commit is contained in:
Dan Buch
2012-05-18 01:33:35 -04:00
parent d6d4cd1ec0
commit b649e10ae8
5 changed files with 76 additions and 152 deletions

20
ares/www/people.json Normal file
View File

@@ -0,0 +1,20 @@
import json
from person_model import PersonModel
from aspen import Response
__people__ = PersonModel()
if GET:
response.body = __people__.getall()
elif POST:
person = json.loads(
request.body.s_iter.read(int(request.headers['Content-Length']))
)['person']
person_id = __people__.add(person)
response.headers['Location'] = '/people/{}.json'.format(person_id)
response.body = {}
raise Response(201)
# vim:filetype=python

6
ares/www/people/%id.json Normal file
View File

@@ -0,0 +1,6 @@
from person_model import PersonModel
__people__ = PersonModel()
response.body = {'person': __people__.get(int(path['id']))}
# vim:filetype=python