【待反馈】python项目部署
为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:免费版 8.0.5系统版本:centos7
问题描述:部署的python项目,启动不起来
相关截图(日志、错误): - Exception on /sock_shell Traceback (most recent call last):File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request()File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1826, in full_dispatch_request return self.finalize_request(rv)File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1847, in finalize_request response = self.process_response(response)File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 2341, in process_response response = self.ensure_sync(func)(response)File "class/flask_compress.py", line 165, in after_request gzip_content = self.get_compress(app, response,'gzip')File "class/flask_compress.py", line 204, in get_compress content = self.compress_gzip(app, response,is_static)File "class/flask_compress.py", line 226, in compress_gzip if response.content_length > 1024 * 20:TypeError: '>' not supported between instances of 'NoneType' and 'int' 您好,这是您自己的代码问题,这段错误日志来自于一个 Flask 应用,具体是在处理一个名为 /sock_shell 的 GET 请求时遇到了异常。错误发生在 Flask 应用的压缩中间件 flask_compress 中,当尝试对响应进行 gzip 压缩时。
下面是一个可能的修复示例,可以参考一下,添加了一个检查以避免当 response.content_length 为 None 时引发错误:
def compress_gzip(self, app, response, is_static):
# ... 其他代码 ...
# 检查 content_length 是否为 None
if response.content_length is None:
# 可以选择跳过压缩,或者设置一个默认值
# 例如,如果内容不大可能超过阈值,可以选择跳过压缩
return response
# 原有的比较操作
if response.content_length > 1024 * 20:
# ... 压缩逻辑 ...
页:
[1]