<commit_before>from http.server import BaseHTTPRequestHandler, HTTPServer
import cv2 

# HTTPRequestHandler class
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):

	# GET
	def do_GET(self):
		# Send response status code
		
		if self.path.endswith('.mjpg'):
			self.send_response(200)
			self.send_header('Content-type','multipart/x-mixed-replace; boundary=--jpgboundary')
			self.end_headers()
			
			while True:
				
				rc, img = capture.read()
				if not rc:
					pass
				r, buf = cv2.imencode(".jpg", img)
				self.wfile.write("--jpgboundary\r\n".encode())
				self.end_headers()
				self.wfile.write(bytearray(buf))
			return
		
		elif self.path.endswith('.html') or self.path == "/":
			self.send_response(200)
			self.send_header('Content-type', 'text/html')
			self.end_headers()
			self.wfile.write('<html><head></head><body>')
			self.wfile.write('<img src="http://localhost:8081/cam.mjpg" height="240px" width="320px"/>')
			self.wfile.write('</body></html>')

def run():
	
	global capture 
	
	capture = cv2.VideoCapture(0)
	
	print('starting server...')

	# Server settings
	# Choose port 8080, for port 80, which is normally used for a http server, you need root access
	server_address = ('127.0.0.1', 8081)
	httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
	print('running server...')
	httpd.serve_forever()<commit_msg>added files<commit_after>from http.server import BaseHTTPRequestHandler, HTTPServer
import cv2 

# HTTPRequestHandler class
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):

	# GET
	def do_GET(self):
		# Send response status code
		
		if self.path.endswith('.mjpg'):
			self.send_response(200)
			self.send_header('Content-type','multipart/x-mixed-replace; boundary=--jpgboundary')
			self.end_headers()
			
			while True:
				
				rc, img = capture.read()
				if not rc:
					pass
				r, buf = cv2.imencode(".jpg", img)
				self.wfile.write("--jpgboundary\r\n".encode())
				self.end_headers()
				self.wfile.write(bytearray(buf))
			return
		
		elif self.path.endswith('.html') or self.path == "/":
			self.send_response(200)
			self.send_header('Content-type', 'text/html')
			self.end_headers()
			self.wfile.write('<html><head></head><body>')
			self.wfile.write('<img src="http://localhost:8081/cam.mjpg" height="240px" width="320px"/>')
			self.wfile.write('</body></html>')

def run():
	
	global capture 
	
	capture = cv2.VideoCapture(0)
	
	print('starting server...')

	# Server settings
	# Choose port 8080, for port 80, which is normally used for a http server, you need root access
	server_address = ('localhost', 8081)
	httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
	print('running server...')
	httpd.serve_forever()
{'fraction_non_alphanumeric': 0.14941262848751835, 'fraction_numerical': 0.024229074889867842, 'mean_word_length': 4.055658627087198, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5493571', 'n_tokens_mistral': 1076, 'n_tokens_neox': 895, 'n_words': 184}