鱼C论坛

 找回密码
 立即注册
查看: 487|回复: 1

django中的中间件中的参数request,response是哪里来的

[复制链接]
发表于 2018-6-26 15:32:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import HttpResponse,render,redirect

class M2(MiddlewareMixin):
    def process_request(self,request):
        print('呵呵呵')

class M1(MiddlewareMixin):
    def process_request(self, request):
        print("MD1里面的 process_request")

    def process_response(self, [b]request[/b], [b]response[/b]):
        print("MD1里面的 process_response")
        print(response)
        return response

打印信息-->
MD1里面的 process_request
[26/Jun/2018 15:29:50] "GET /a/ HTTP/1.1" 200 324
MD1里面的 process_response
<HttpResponse status_code=200, "text/html; charset=utf-8">
<WSGIRequest: GET '/a/'>

参数request,response是什么内容?怎么来的?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-26 15:42:42 | 显示全部楼层
request想明白了,应该是浏览器访问页面的时候发送的request的请求,response是响应,应该是返回请求的路径的文件,但是我将文件名改掉,应该返回404,奇怪的是,返回的还是200,如果是这样的话,response返回的到底是什么?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-4 18:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表