Created
June 17, 2020 17:47
-
-
Save CoMPaTech/334d4823ed81b82a5a3e4fe6b59cd473 to your computer and use it in GitHub Desktop.
zeroconf discovery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zeroconf import ServiceBrowser, Zeroconf | |
class MyListener: | |
def remove_service(self, zeroconf, type, name): | |
print("Service %s removed\n" % (name,)) | |
def add_service(self, zeroconf, type, name): | |
info = zeroconf.get_service_info(type, name) | |
print("Service %s added, service info: %s\n" % (name, info)) | |
zeroconf = Zeroconf() | |
listener = MyListener() | |
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener) | |
try: | |
input("Press enter to exit...\n\n") | |
finally: | |
zeroconf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment