def do_GET(self): global cameraQuality try: self.path = re.sub('[^.a-zA-Z0-9]', "", str(self.path)) if self.path == "" or self.path==None or self.path[:1]==".": return if self.path.endswith(".html"): f = open( curdir + sep + self.path ) self.send_response(200) self.send_header('Content-type','text/html') self.end_headers() self.wfile.write( f.read() ) f.close() return if self.path.endswith(".mjpeg"): self.send_response(200) self.wfile.write("content-Type: multipart/x-mixed-replace; boundary=--aaboundary") self.wfile.write("\r\n\r\n") while 1: output = MainLoopHTTPServer.getOutputStream() retval, cv2mat= cv2.imencode(".jpeg",output,(cv.CV_IMWRITE_JPEG_QUALITY,cameraQuality)) jpegData = cv2mat.tostring() self.wfile.write("--aaboundary\r\n") self.wfile.write("Content-Type: image/jpeg\r\n") self.wfile.write("Content-length: "+str(len(jpegData))+"\r\n\r\n") self.wfile.write(jpegData) self.wfile.write("\r\n\r\n\r\n") time.sleep(0.05) return return except IOError: self.send_error(404,'File Not Found: %s' % self.path)