14

I share files in a folder to other devices by invoking a server using python -m SimpleHTTPServer.

I just tried to stream videos/audio (standard mp4 & mp3, both under 20MB) to another computer using this & it WORKS (but by throwing the errors (listed down) in the terminal).

Somehow, the video/audio fails (except very small mp3 files) to play with Safari in iPhone/iPad. It is definitely not related to the media files, as I streamed them successfully using Apache in iPhone.

Any idea why it happens?

Exception happened during processing of request from ('192.168.1.2', 51775)
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 641, in __init__
    self.finish()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
Jikku Jose
  • 18,306
  • 11
  • 41
  • 61
  • 1
    Check out these [alternatives](http://stackoverflow.com/questions/12905426/faster-alternative-to-pythons-simplehttpserver) to Python's SimpleHTTPServer module. – mtadd Aug 03 '13 at 19:17
  • 1
    Off topic to use Python's built-in web server for prototyping? Quoting from the reason listed as off topic: "describe the problem" = Ran SimpleHTTPServer & received exception (still happening in 2018), and "what has been done so far to solve it" => verified not audio file problem. Therefore, must be a Python standard library implementation bug. How is this off topic for a website dedicated to programming languages and their standard libraries? – michael May 21 '18 at 14:09
  • None of the alternatives linked to above are even listed in the latest [Top 10 Python full stack or microframeworks](https://stackoverflow.com/questions/18035433/audio-video-streaming-fails-using-simplehttpserver?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) anymore. Web frameworks come and go like vapors. This is why a language's standard library is always preferable to spiraling off into the latest 3rd party fad, especially when getting started. – michael May 21 '18 at 14:20

1 Answers1

8

As sugested either use python alternatives, What is a faster alternative to Python's http.server (or SimpleHTTPServer)? or use full blown web serwer altogether. Quick google suggests that Mac supports both Nignx and Apache2.

Community
  • 1
  • 1
jb.
  • 23,300
  • 18
  • 98
  • 136
  • 2
    Thanks for the links to the alternatives but the [marked answer](http://stackoverflow.com/a/12905427/2602869) that suggested [http-server](https://github.com/nodeapps/http-server) (for node.js) didn't seem to stream video files. But, [twistd](http://http://twistedmatrix.com) (for Python) as explained in [another answer](http://stackoverflow.com/a/14618010/2602869) does it pretty well! – Jikku Jose Aug 04 '13 at 05:29
  • @JikkuJose how can I start _twisted_ in terminal? Also correct link of twisted [is here](http://twistedmatrix.com). – S.M.Mousavi Jul 07 '16 at 17:42
  • What is the actual reason for this issue? Alternatives can be listed but the reason for failure is not made clear. – WestCoastProjects Jun 11 '20 at 00:34