Hug API Development Server

def hug(file: 'A Python file that contains a Hug API'=None, module: 'A Python module that contains a Hug API'=None,
        host: 'Interface to bind to'='', port: number=8000, no_404_documentation: boolean=False,
        manual_reload: boolean=False, interval: number=1,
        command: 'Run a command defined in the given module'=None,
        silent: boolean=False):
    """Hug API Development Server"""
    api_module = None
    if file and module:
        print("Error: can not define both a file and module source for Hug API.")
        sys.exit(1)
    if file:
        sys.path.append(os.path.dirname(os.path.abspath(file)))
        sys.path.append(os.getcwd())
        api_module = importlib.machinery.SourceFileLoader(file.split(".")[0], file).load_module()
    elif module:
        sys.path.append(os.getcwd())
        api_module = importlib.import_module(module)
    if not api_module or not hasattr(api_module, '__hug__'):
        print("Error: must define a file name or module that contains a Hug API.")
        sys.exit(1)

    api = API(api_module, display_intro=not silent)
    if command:
        if command not in api.cli.commands:
            print(str(api.cli))
            sys.exit(1)

        sys.argv[1:] = sys.argv[(sys.argv.index('-c') if '-c' in sys.argv else sys.argv.index('--command')) + 2:]
        api.cli.commands[command]()
        return

    ran = False
    if not manual_reload:
        thread.start_new_thread(reload_checker, (interval, ))
        while True:
            reload_checker.reloading = False
            time.sleep(1)
            try:
                _start_api(api_module, host, port, no_404_documentation, False if silent else not ran)
            except KeyboardInterrupt:
                if not reload_checker.reloading:
                    sys.exit(1)
                reload_checker.reloading = False
                ran = True
                for name in list(sys.modules.keys()):
                    if name not in INIT_MODULES:
                        del(sys.modules[name])
                if file:
                    api_module = importlib.machinery.SourceFileLoader(file.split(".")[0],
                                                                        file).load_module()
                elif module:
                    api_module = importlib.import_module(module)
    else:
        _start_api(api_module, host, port, no_404_documentation, not ran)