from http.server import HTTPServer from Code.Communication.Neighbours import Neighbours from Code.Communication.RequestHandler import RequestHandler class Server: def __init__(self, neighbours: Neighbours): self.neighbours = neighbours self.port = neighbours.own_process.port self.ip = neighbours.own_process.ip def stop_server(self): print("Trying to stop server") self.server.shutdown() def start(self): RequestHandler.neighbours = self.neighbours print(f"HTTP Server Running on {self.ip}: {self.port}") self.server = HTTPServer((self.ip, self.port), RequestHandler) self.server.serve_forever() print("Stopped server")