Python - Http服务器,如何发送.ico文件?

问题描述 投票:0回答:1

我创建了一个HTTP服务器,它返回图像,文本和图标。图像和文本按要求工作,看起来没问题。但是,图标根本不显示。

看起来我的HTTP服务器将解码后的图标发送给客户端,但图标没有出现。我检查过,文件存在。我认为解码方式不正确所以客户端无法在他的网站上看到图标。

我以这种方式解码图标(.ico文件):

file_des = open(file_name, 'rb')  # as binary
icon_stream = file_des.read()
# then send to the client socket and it gets the data, but no icon is appears.

我怎么解决这个问题?

非常感谢你。

python sockets http decode
1个回答
3
投票

如果其他一切运作良好,我猜你是混淆MIME类型。我使用image/vnd.microsoft.icon并且不需要任何额外的数据处理。

© www.soinside.com 2019 - 2024. All rights reserved.