Get Host Name Without Port in Flask
There is no Werkzeug (the WSGI toolkit Flask uses) method that returns the hostname alone.What you can do is use Python's urlparse module to get the hostname from the result Werkzeug gives you:
python 3
from urllib.parse import urlparseo = urlparse(request.base_url)print(o.hostname)
python 2
from urlparse import urlparse o = urlparse("http://127.0.0.1:5000/")print(o.hostname) # will display '127.0.0.1'