Trying to figure out URL dispatcher for sluggale URLs like stackoverflow

Posted by TylerW on Stack Overflow See other posts from Stack Overflow or by TylerW
Published on 2010-05-28T20:01:56Z Indexed on 2010/05/28 20:12 UTC
Read the original article Hit count: 245

Filed under:
|
|

I'm using the Tornado framework (Python). I have the sluggable URLs working. But I have 3 different entries in the URL dispatcher. I was wondering if someone could help me transform it into one line.

This is what I have:

(r"/post/([0-9]+)/[a-zA-Z0-9\-]+", SpotHandler),
(r"/post/([0-9]+)/", SpotHandler),
(r"/post/([0-9]+)", SpotHandler),

I want it so that the following URLs all go to the same place.

http://domain.com/post/14

http://domain.com/post/14/

http://domain.com/post/14/any-text-it-doesnt-matter-what-it-is

© Stack Overflow or respective owner

Related posts about python

Related posts about slug