Home | Mirror | Search

2. Django

wget http://www.djangoproject.com/download/0.96/tarball/
tar zxvf Django-0.96.tar.gz
cd Django-0.96
python setup.py install
		

生成項目

django-admin.py startproject newtest
		

web server

cd newtest/
./manage.py runserver
		

helloworld.py

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, Django.")
		

urls.py

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    # Example:
    # (r'^newtest/', include('newtest.foo.urls')),
    (r'^$', 'newtest.helloworld.index'),

    # Uncomment this for admin:
#     (r'^admin/', include('django.contrib.admin.urls')),
)
		

啟動Web Server

# ./manage.py runserver
Validating models...
0 errors found.

Django version 0.96, using settings 'newtest.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
		

curl http://127.0.0.1:8000/

comments powered by Disqus