`

Django3(HelloWorld例子)

 
阅读更多
1. views.py
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了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics