django学习日志(View视图)第四部分:Request对象和Response对象
- 创建一个路由
- WhatsView\App\urls.py
urlpatterns = [
url(r'^ url(r'^reqandresp/', views.reqAndResp, name='reqresp'),
]
def reqAndResp(request):
print("request=",request)
resp = HttpResponse()
resp.status_code = 404
resp.content = '......'
resp.write('request.path='+request.path+";")
resp.write('request.method='+request.method+";")
resp.write('name='+request.GET.get('name')+";")
resp.write('age='+request.GET.get('age')+";")
return resp
- http://127.0.0.1:8000/app/reqandresp/?name=bill&age=20