Traditional Web Development
Most web applications use the same base URI to handle the serving of resources and the manipulation of resources. For instance, it's common to find something such as the following:
URI |
Request Body |
HTTP Method |
Operation |
---|---|---|---|
|
N/A |
GET |
Fetch all albums |
|
N/A |
GET |
Fetch the album with the ID 12 |
|
N/A |
GET |
Return a form to perform an action on a resource |
|
title=Friends |
POST |
Create an album |
|
id=12 |
POST |
Delete the album with the ID 12 |
|
id=12&title=Family |
POST |
Update the album with the ID 12 |
Within an application hosted with CherryPy, this could be translated into:
class Album: @cherrypy.expose def index(self, id=None): # returns all albums as HTML or the one # requested by the id parameter if provided @cherrypy.expose def edit(self, id=None): # returns an HTML page with a form to perform # an action on a resource...