Tuesday, January 4, 2011

How to reformat URLs to be more restful (from .../?id=123 to .../123)?

Programmer Question

Currently I have pages accessed via:



www.foo.com/details.html?id=123


I'd like to make them more restful-like, such as by the following:



www.foo.com/details/123


I'm using Google App Engine. Currently the URL's are mapped in the html-mappings file:



 ('/details.html*', DetailsPage),


And then on the DetailsPage handler, it fetches the ID value via:



class DetailsPage(webapp.RequestHandler):
def get(self):
announcement_id = self.request.get("id")


How might I restructure this so that it can map the URL and a extract the ID via the other-formatted URL: www.foo.com/details/123



Thanks



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails