我正在使用 Python Flask。我想通过权限检查向用户发送媒体文件(mp4、mp3、mov 等)。我将使用数据库检查用户权限,并且我只想为经过身份验证的用户发送文件。
所以我开始开发那个系统。我使用登录检查权限,我使用 Send_file 向用户发送文件。在桌面上,它运行良好。但在我的 iPad、iPhone、Android 手机上,它不起作用。他们的播放器警报“无法播放此视频”。在 iPhone 中,播放器的播放按钮不可用。
iPhone 错误屏幕截图在这里 http://webhost.swisscom.co.kr/temp/stackoverflow_iphone1.jpg
烧瓶服务器(Gunicorn)返回
“错误:[Errno 107] 传输端点未连接”。python flask调试服务器时-》报错:[Error 32] Broken pipe.
我在超过 5 个不同的服务器上进行了测试,但它仍然无法正常工作。
我还使用了 x-sendfile 或 send_from_directory,手动构建响应标头。
@app.route('/download/<path:filename>')
def download(filename):
return send_file('data/file/' + filename)
在 iOS7、iOS6、android 中请求视频时出现 Gunicorn Flask Server 错误
2013-10-17 16:38:46 [14344] [ERROR] Error processing request.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 88, in handle
self.handle_request(listener, req, client, addr)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 145, in handle_request
client.shutdown(socket.SHUT_RDWR)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 107] Transport endpoint is not connected
2013-10-17 16:38:47 [14331] [ERROR] Error processing request.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 88, in handle
self.handle_request(listener, req, client, addr)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 145, in handle_request
client.shutdown(socket.SHUT_RDWR)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 107] Transport endpoint is not connected
在 iOS7 或 iOS6 或 android 中请求视频时 Python 调试器服务器错误
123.123.123.123 - - [17/Oct/2013 16:34:36] "GET /download/welcome.mp4 HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('110.70.52.201', 38723)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 704, 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