dimanche 20 décembre 2015

Serving video website based onTornado

I'm new to tornado and I want build a simple website for watching movie. Of course,hello world website is successful and I want to add a movie in the empty website.Therefore I write a html using video label in html 5.

<html>
<body>
<video  autoplay=true> 
<source src="aa.mp4" type="video/mp4"></source> 
</video>
</body>
</html>

The code in tornado is simple as well.

class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        self.render('index.html')

A picture is OK, but when I use video which is 500MB. MemoryError arise.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1141, in _when_complete
    callback()
  File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1167, in _execute_finish
    self.finish()
  File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 760, in finish
    self.flush(include_footers=True)
  File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 703, in flush
    chunk = b"".join(self._write_buffer)
MemoryError

I feel like the problem is the browser download the whole video,So the function cannot return and throw a exception. Is it right? And how to fix it,thanks a lot.




Aucun commentaire:

Enregistrer un commentaire