Skip to content

Instantly share code, notes, and snippets.

@tab1293
Created September 22, 2014 17:58
Show Gist options
  • Save tab1293/8ca3eb79eb30244e4523 to your computer and use it in GitHub Desktop.
Save tab1293/8ca3eb79eb30244e4523 to your computer and use it in GitHub Desktop.
application = tornado.web.Application([
(r"/test/(.*?)", StaticTrackHandler, {"path": "/home/ubuntu/echostream/tracks"}),
], debug=True)
class StaticTrackHandler(tornado.web.StaticFileHandler):
@classmethod
def get_current_user(self):
return self.get_secure_cookie('user')
@classmethod
def get_content(self, abspath, start=None, end=None):
if self.current_user:
r = requests.get('https://s3.amazonaws.com/echostream-tracks/587b3e4e2a274a06b3b18ce42674af72', stream=True)
return r.iter_lines()
else:
self.redirect('/login')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment