def __init__(self, server_address, handler_class, certfile): BaseHTTPServer.__init__(self, server_address, handler_class) self.certfile = certfile
for pattern, handler in self.handlers.items(): matches = re.match(pattern, self.path) if matches: handler(*matches.groups()) return # No handler found self.send_response(404) self.end_headers() if __name__ == "__main__": try: with open('config.json', 'rb') as f: config = json.loads(f.read().decode('utf-8')) except: print('Unable to load config file') sys.exit(1) market = Market(config['email'], config['password']) market.login() operator = Operator(config['country'], config['operator']) try: server = HTTPServer(('', 5000), ApkServerHandler) server.serve_forever() except KeyboardInterrupt: print('^C received, shutting down the web server') server.socket.close()