Skip to content

Instantly share code, notes, and snippets.

@rmax
Created July 8, 2010 23:08
Show Gist options
  • Save rmax/468786 to your computer and use it in GitHub Desktop.
Save rmax/468786 to your computer and use it in GitHub Desktop.
""" file mytest.py """
# you require to return a HttpResponse instance in your view
from django.http import HttpResponse
# handler* are required for the urlresolver
from django.conf.urls.defaults import patterns, handler404, handler500
# minimal settings
DEBUG = True
# tell django to use this file to find urlpatterns. see below
ROOT_URLCONF = "mytest"
# a basic callback to return something to the user. "view" in django's idiom
def myview(request):
# you can use html content if you want
return HttpResponse("Boo!")
# finally tie a url route to our view
urlpatterns = patterns("",
# the regex is used to match whatever after /
# ^$ means "nothing", so route the url / to our callback "myview"
(r"^$", myview),
)
# /end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment