Using aspen instead of homespun wsgi thingy
This commit is contained in:
20
ares/www/people.json
Normal file
20
ares/www/people.json
Normal 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
6
ares/www/people/%id.json
Normal file
@@ -0,0 +1,6 @@
|
||||
from person_model import PersonModel
|
||||
__people__ = PersonModel()
|
||||
|
||||
response.body = {'person': __people__.get(int(path['id']))}
|
||||
|
||||
# vim:filetype=python
|
Reference in New Issue
Block a user