If you want to catch variable length url parameters with tornado, first, you have to setup the correct regex routes:
(r"/some_method/?(?P<param_name>[A-Za-z0-9-]+)?/", FunctionHandler)
Don't forget to enclose the param groups (?P ... )
between question marks ?(?P ... )?
to mark them as non-mendatory.
The function handler is like:
class FunctionHandler(tornado.web.RequestHandler):
def get(self, **params):
self.render("some_template_file.html",
params = params,
)
You'll be able to use the parameters variable in your template as follow:
params["param_name"]
Posted by ThEo.GFX to ThEo.GFX's Cards (2012-09-25 14:43)