Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alternative method to determine user computer's IP address when using flet run --os/--android #1733

Closed
FeodorFitsner opened this issue Aug 15, 2023 · 2 comments
Labels
enhancement Improvement/Optimization

Comments

@FeodorFitsner
Copy link
Contributor

import socket
def get_local_ip():
    try:
        with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
            s.connect(("8.8.8.8", 80))
            local_ip = s.getsockname()[0]
        return local_ip
    except Exception as e:
        return f"Unable to get local IP address: {e}"

# Example usage
local_ip_address = get_local_ip()
print(f"Your laptop's local IP address is {local_ip_address}")

Source: #1715 (comment)

@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Aug 15, 2023

The except could contain the actual IP-retrieval way. Kind of a fallback.
What do you think?

@FeodorFitsner
Copy link
Contributor Author

@ndonkoHenri sounds right!

zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* Use alternative method to determine user computer's IP

Close flet-dev#1733

* Fix Cavas.Text drawing

Fix flet-dev#1783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement/Optimization
Projects
None yet
Development

No branches or pull requests

2 participants