m3u8 proxy for shortcut.lv streams

mtbottle.py 683B

123456789101112131415161718192021222324252627282930
  1. '''Multithreading Bottle server adapter.'''
  2. import bottle
  3. import mtwsgi
  4. class MTServer(bottle.ServerAdapter):
  5. def run(self, handler):
  6. thread_count = self.options.pop('thread_count', None)
  7. server = mtwsgi.make_server(self.host, self.port, handler, thread_count, **self.options)
  8. server.serve_forever()
  9. if __name__ == '__main__':
  10. import bottle
  11. import time
  12. app = bottle.Bottle()
  13. @app.route('/')
  14. def foo():
  15. time.sleep(2)
  16. return 'hello, world!\n'
  17. app.run(server=MTServer, host='0.0.0.0', port=8080, thread_count=3)
  18. # or:
  19. # httpd = mtwsgi.make_server('0.0.0.0', 8080, app, 3)
  20. # httpd.serve_forever()