import requests


def find_server(host, input_foo, print_foo):
    """
    Function used to check connection with server.
    :param host: string with address to game server in IP:PORT format
    :param input_foo: functor with function used to get input from user
    :param print_foo: functor with function used to show output to user
    :return: checked and correct string with address to working server
    """
    while True:
        try:
            response = requests.get(f"http://{host}/")
            if response.status_code == 200:
                print_foo("Connection to Game Server checked.")
                break
        except requests.exceptions.ConnectionError as ex:
            print_foo(f'Exception: {ex}')
            print_foo(f"Game Server at {host} are not responding.")
            host = input_foo("Enter host address in IP:PORT format: ")
    return host