我从来没有见过的python -m SimpleHTTPServer
伎俩。但我试了一下,并得到它来服务于一些静态文件。然而,当我试图服务于大量的MP4文件,支持视频标签,我看到这个输出(与服务器保持运行):
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 693, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
你看到了吗?这是Linux上的Python 2.7.3;它看起来像你在Mac OS X上,所以它可能看起来有点不同。
无论如何,我在iPad上看到了相同的断开重放图标。我猜测,简单的Python HTTP服务器并不知道如何一次处理那么多的数据。
替代解决方案:如果您现在需要的只是一个简单的静态的准系统HTTP服务器,我推荐webfs。将其编译到命令行并从任意位置执行以在端口8000上建立非特权静态HTTP服务器(默认情况下)。我只是测试了一下,并且能够通过Safari中的视频标签将基本.MP4文件流式传输到iPad。