Examples¶
A simple way to run any of these examples is with gunicorn:
gunicorn -b localhost:8000 test:application
Hello World!¶
import antfarm
def index(request):
return antfarm.Response('Hello World!')
application = antfarm.App(root_view=index)
Simple URL routing¶
import antfarm
from antfarm.views.urls import url_dispatcher
def index(request):
return antfarm.Response('Index')
def detail(request, user_pk):
return antfarm.Response('You asked for %s' % user_pk)
application = antfarm.App(
root_view = url_dispatcher(
(r'^/$', index),
(r'^/details/(?P<user_pk>\d+)/$', detail),
)
)