<commit_before>import socket
'''
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(("127.0.0.1",8080))
sock.listen(5)
print "waiting for a connection..."
(clientsock,address) = sock.accept()
print "got something..."
sockFile=clientsock.makefile()
msg="nothing"
while len(msg)>0 and msg<>"\r\n":
	msg=sockFile.readline()
	print repr(msg)
sockFile.close
clientsock.shutdown(1)
clientsock.close()
sock.close()
'''
class SijperServer:

	def __init__(self,addr,port):
		self.sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
		sock.bind((addr,port))
		sock.listen(5)
	
	class ClientThread(threading.Thread):
		def __init__(self,clientsock,address):
			self.clientsock=clientsock
			self.address=address
		def run(self):
			sockfile=clientsock.makefile()
			while True:
				msg=sockFile.readline()
				if len(msg)==0 or msg=="\r\n":
					break 
			sockFile.close()
			self.clientsock.shutdown(1)
			self.clientsock.close()
	def stop(self):
		self.runFlag=False

	def start(self):
		self.runFlag=True
		while self.runFlag:
			(clientsock,address) = self.sock.accept()
			ct=ClientThread(clientsock,address)
			ct.start()
<commit_msg>basic HTTP server support<commit_after>import threading
import socket
'''
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(("127.0.0.1",8080))
sock.listen(5)
print "waiting for a connection..."
(clientsock,address) = sock.accept()
print "got something..."
sockFile=clientsock.makefile()
msg="nothing"
while len(msg)>0 and msg<>"\r\n":
	msg=sockFile.readline()
	print repr(msg)
sockFile.close
clientsock.shutdown(1)
clientsock.close()
sock.close()
'''
class SijperServer(threading.Thread):

	def __init__(self,addr,port):
		super(SijperServer,self).__init__()
		self.sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
		self.sock.bind((addr,port))
		self.sock.listen(5)
	
	'''
	start of ClientThread
	'''

	class ClientThread(threading.Thread):
		def __init__(self,clientsock,address):
			super(SijperServer.ClientThread,self).__init__()
			self.clientsock=clientsock
			self.address=address
		def run(self):
			sockFile=self.clientsock.makefile()
			try:
				while True:
					msg=sockFile.readline()
					if len(msg)==0 or msg=="\r\n":
						break
					self.processMsg(msg)
				
				if msg=="\r\n":
					data=sockFile.read(self.contentlength)
					parsedict={}
					for pair in data.split("&"):
						p=pair.split("=")
						parsedict[p[0]]=p[1]
					print parsedict
					sockFile.write("200 OK")
					sockFile.flush()
			finally:
				sockFile.close()
				self.clientsock.shutdown(1)
				self.clientsock.close()

		def processMsg(self,msg):
			if msg.startswith("Content-Length"):
				self.contentlength=int(msg[len("Content-Length: "):])


	'''
	end of ClientThread
	'''

	def stop(self):
		self.runFlag=False
		self.sock.shutdown(1)
		self.sock.close()

	def run(self):
		self.runFlag=True
		try:
			while self.runFlag:
				(clientsock,address) = self.sock.accept()
				ct=self.ClientThread(clientsock,address)
				ct.start()
		finally:
			self.sock.shutdown(1)
			self.sock.close()


sijp=SijperServer("127.0.0.1",8081)
sijp.start()
{'fraction_non_alphanumeric': 0.15789473684210525, 'fraction_numerical': 0.015821762996448177, 'mean_word_length': 4.425569176882662, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '4284701', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1150, 'n_words': 178}