Route handling

pyroutes.route(path)

Decorator for declaring a method as a handler for a specific path, and paths above it if no better match exists. The decorated method should take an instance of pyroutes.http.request.Request as its first argument, and optionally more arguments auto-populated from the path.

All handler methods must return an instance of pyroutes.http.response.Response.

pyroutes.reverse_url(handler)

Return the path a handler is responible for.

Example:

@pyroutes.route('/foo/bar')
def foo_method(request):
    return "foo"

pyroutes.reverse_url('foo_method')
'/foo/bar'

Project Versions

Go to this page on GitHub. (Edit)

Previous topic

Middleware

Next topic

Request and response objects

This Page