当前位置:论坛首页 > Linux面板 > 求助

【待反馈】python项目部署

发表在 Linux面板2024-3-27 11:48 [复制链接] 1 158

为了能快速了解并处理您的问题,请提供以下基础信息:
面板、插件版本:免费版 8.0.5
系统版本:centos7
问题描述:部署的python项目,启动不起来

相关截图(日志、错误):
[2024-03-27 11:28:36,212][ERROR] - Exception on /sock_shell [GET]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'
使用道具 举报 只看该作者 回复
发表于 2024-3-30 10:26:00 | 显示全部楼层
您好,这是您自己的代码问题,这段错误日志来自于一个 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:  
        # ... 压缩逻辑 ...
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

企业版年付运维跟进群

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急问题处理

论坛响应时间:10分钟

问题处理方式:1对1处理(优先)

工作时间:白班:9:00 - 18:00

工作时间:晚班:18:00 - 24:00

立即付费处理
快速回复 返回顶部 返回列表