def render_GET(self, request): request.setHeader("Content-Type", "image/gif") request.setHeader("Cache-Control", "max-age=2000") request.setHeader("Connection", "close") try: v_path = os.path.join(config.VOD_RES_DIR, self.vod_id) if request.args.get("head", 0): frag = Fragment(file(v_path)) frag.slice_head() return frag.flush() start = long(request.args.get("start")[0]) offset = long(request.args.get("length")[0]) fd = os.open(v_path, os.O_RDONLY) os.lseek(fd, start, os.SEEK_SET) data = os.read(fd, offset) os.close(fd) return data except Exception, e: traceback.print_exc(file=sys.stderr) return str(e)
def render_GET(self, request): request.setHeader('Content-Type', 'image/gif') request.setHeader('Cache-Control', 'max-age=2000') request.setHeader('Connection', 'close') try: v_path = os.path.join(config.VOD_RES_DIR, self.vod_id) if request.args.get('head', 0): frag = Fragment(file(v_path)) frag.slice_head() return frag.flush() start = long(request.args.get('start')[0]) offset = long(request.args.get('length')[0]) fd = os.open(v_path, os.O_RDONLY) os.lseek(fd, start, os.SEEK_SET) data = os.read(fd, offset) os.close(fd) return data except Exception, e: traceback.print_exc(file=sys.stderr) return str(e)