from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def test(request):
# print(request) # <WSGIRequest: GET '/app/test/'> 请求对象
print(request.method) # 请求方式GET
print(request.GET) # GET参数<QueryDict: {}>
print(request.GET.get('name')) # GET参数获取域名得汇总name得参数
print(request.GET.getlist('name')) # 获取域名里面的名字列表参数
print(request.POST) # POST参数<QueryDict: {}>
print(request.path) # path路径参数/app/test/
print(request.get_full_path) # 打印完整路径
print(
request.COOKIES) # 会话技术{'csrftoken': 'JjuvXMJv1aQ41wcLn1rqnXi3hqAZO7Rs', 'sessionid': 'izlsvufx848ucpqk0a5gg636a3vlsqno'}
print(request.session) # <django.contrib.sessions.backends.db.SessionStore object at 0x0000018E6461EE50>
print(request.FILES) # 上传文件
print(request.META['REMOTE_ADDR']) # 客户端ip地址
return HttpResponse("测试返回")
|