-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
ekampf edited this page Sep 6, 2010
·
3 revisions
In Ignition, a route is an Python decorator that matches an HTTP method and a URL pattern to a view function:
@get('/')
def index(request):
... show something ...
@post('/')
def index(request):
... create something ...
@put('/')
def index(request):
... update something ...
@delete('/')
def index(request):
... destroy something ...
Routes are matched in the order in which they are defined. The first route that matches the request is invoked.
Route patterns can include names:
@get('/{year:\d\d\d\d}/{month:\d\d}/'')
def index(request, year, month):
return "Hello from the year %s" % year
To immediately stop a request use:
halt()
You can also specify the status, explanation and response headers when halting:
halt(code=401, explanation="Get outta here!", headers=[('Content-Type', 'text/html'), ])
- Issue Tracker Issue Tracker
- Eran Kampf's Blog - DeveloperZen