How to use the gradio.networking function in gradio

To help you get started, we’ve selected a few gradio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gradio-app / gradio-UI / test / test_networking.py View on Github external
initial = 7000
        final = 8000
        port_found = False
        for port in range(initial, final):
            try:
                s = socket.socket()  # create a socket object
                s.bind((LOCALHOST_NAME, port))  # Bind to the port
                s.close()
                port_found = True
                break
            except OSError:
                pass
        if port_found:
            s = socket.socket()  # create a socket object
            s.bind((LOCALHOST_NAME, port))  # Bind to the port
            new_port = networking.get_first_available_port(initial, final)
            s.close()
        self.assertFalse(port==new_port)
github gradio-app / gradio-UI / build / lib / gradio / interface.py View on Github external
latest_pkg_version = requests.get(url=PKG_VERSION_URL).json()["version"]
            if StrictVersion(latest_pkg_version) > StrictVersion(current_pkg_version):
                print(f"IMPORTANT: You are using gradio version {current_pkg_version}, "
                      f"however version {latest_pkg_version} "
                      f"is available, please upgrade.")
                print('--------')
        except:  # TODO(abidlabs): don't catch all exceptions
            pass

        if self.verbose:
            print(strings.en["BETA_MESSAGE"])
            if not is_colab:
                print(strings.en["RUNNING_LOCALLY"].format(path_to_local_server))
        if share:
            try:
                share_url = networking.setup_tunnel(server_port)
            except RuntimeError:
                share_url = None
                if self.verbose:
                    print(strings.en["NGROK_NO_INTERNET"])
        else:
            if (
                is_colab
            ):  # For a colab notebook, create a public link even if share is False.
                share_url = networking.setup_tunnel(server_port)
                if self.verbose:
                    print(strings.en["COLAB_NO_LOCAL"])
            else:  # If it's not a colab notebook and share=False, print a message telling them about the share option.
                if self.verbose:
                    print(strings.en["PUBLIC_SHARE_TRUE"])
                share_url = None