hostname

Get Request Host Name Without Port in Flask

Get Request Host Name Without Port in Flask Question: I’ve just managed to get my app server hostname in Flask using request.host and request.url_root, but both field return the request hostname with its port. I want to use field/method that returns only the request hostname without having to do string replace, if any. Asked By: …

Total answers: 5

python: check if a hostname is resolved

python: check if a hostname is resolved Question: How can I have a function in python that returns 1 if the a hostname resolves and 0 if a hostname does not. I couldn’t find anything useful, any thoughts? Thanks, Asked By: Amir || Source Answers: You can use socket.gethostbyname() for this: >>> import socket >>> …

Total answers: 1

How can I use Python to get the system hostname?

How can I use Python to get the system hostname? Question: I’m writing a chat program for a local network. I would like be able to identify computers and get the user-set computer name with Python. Asked By: John || Source Answers: Use socket and its gethostname() functionality. This will get the hostname of the …

Total answers: 12

Python lookup hostname from IP with 1 second timeout

Python lookup hostname from IP with 1 second timeout Question: How can I look up a hostname given an IP address? Furthermore, how can I specify a timeout in case no such reverse DNS entry exists? Trying to keep things as fast as possible. Or is there a better way? Thank you! Asked By: ensnare …

Total answers: 2

Validate a hostname string

Validate a hostname string Question: Following up to Regular expression to match hostname or IP Address? and using Restrictions on valid host names as a reference, what is the most readable, concise way to match/validate a hostname/fqdn (fully qualified domain name) in Python? I’ve answered with my attempt below, improvements welcome. Asked By: kostmo || …

Total answers: 10