gpt4 book ai didi

python - 为 aiohttp 中的静态文件启用 gzip 压缩

转载 作者:太空宇宙 更新时间:2023-11-03 15:54:38 67 4
gpt4 key购买 nike

我也尝试在静态文件中启用 aiohttp 压缩。我尝试创建自定义响应:

import aiohttp

class GzipResponse(aiohttp.web.StreamResponse):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enable_compression()

并将其作为工厂添加到静态路由中:

app.router.add_static("prefix", "path", response_factory=GzipResponse)

但是它不起作用。

最佳答案

也许它不起作用,因为如果设置了压缩,当前 sendfile 方法不会切换到回退。

关于python - 为 aiohttp 中的静态文件启用 gzip 压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40912743/

67 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com