我從來沒有見過的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。