import cv2 from urllib import request cap = cv2.VideoCapture('http://127.0.0.1:8080/camera') while True: ret,frame = cap.read() cv2.imshow("capture", frame) key = cv2.waitKey(1) if key== ord('q'): break elif key == ord('w'): print('send request') req = request.urlopen('http://127.0.0.1:8080/control?director=w') res = req.read() print(res) elif key == ord('s'): print('send request') req = request.urlopen('http://127.0.0.1:8080/control?director=s') res = req.read() print(res) elif key == ord('a'): print('send request') req = request.urlopen('http://127.0.0.1:8080/control?director=a') res = req.read() print(res) elif key == ord('d'): print('send request') req = request.urlopen('http://127.0.0.1:8080/control?director=d') res = req.read() print(res)