/usr/lib/python2.7/dist-packages/pecan/scaffolds/rest-api/+package+/controllers/root.py is in python-pecan 0.6.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from pecan import expose, response, abort
from pecan.rest import RestController
people = {
1: 'Luke',
2: 'Leia',
3: 'Han',
4: 'Anakin'
}
class PeopleController(RestController):
@expose('json')
def get_all(self):
return people
@expose()
def get_one(self, person_id):
return people.get(int(person_id)) or abort(404)
@expose()
def post(self):
# TODO: Create a new person
response.status = 201
@expose()
def put(self, person_id):
# TODO: Idempotent PUT (returns 200 or 204)
response.status = 204
@expose()
def delete(self, person_id):
# TODO: Idempotent DELETE
response.status = 200
class RootController(object):
people = PeopleController()
@expose()
def index(self):
return "Hello, World!"
|