1. views.py
2. urls.py
3. 访问:
输入http://localhost:8080
或http://localhost:8080/hello 便可以访问到helloworld了。
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world")
2. urls.py
from django.conf.urls.defaults import patterns, include, url
from mysite.views import hello
urlpatterns = patterns('',
('^hello/$',hello),
# set default page
('^$',hello),
)
3. 访问:
输入http://localhost:8080
或http://localhost:8080/hello 便可以访问到helloworld了。