Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

第 7 章 Web framework

目录

7.1. Django
7.2. Pylons
7.2.1. Getting Started with Pylons
7.2.2. config/routing.py
7.2.3. mako template
7.3. Pyramid
7.3.1. Getting Started
7.3.2. Creating a Pyramid Project

http://wiki.secondlife.com/wiki/Mulib

7.1. 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/