Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1694788
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类: Python/Ruby

2010-01-06 20:50:15

1、创建 add.py 文件,内容如下:
 
from django.http import HttpResponse
text = """

   +
  
  
  
"""
def index(request):
    if request.POST.has_key('a'):
        a = int(request.POST['a'])
        b = int(request.POST['b'])
    else:
        a = 0
        b = 0
    return HttpResponse(text % (a,b,a+b))
 
 
 
 
2、修改urls.py:
from django.conf.urls.defaults import *

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

    # Uncomment this for admin:
#     (r'^admin/', include('django.contrib.admin.urls')),
)
3、重启apache服务器
4、 浏览察看结果
结果如下:

 
阅读(1105) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~