How to show my IP Address on Flask? How to show my IP Address on Flask? flask flask

How to show my IP Address on Flask?


The request object has a .host attribute, but that includes the port number, if available. To get just the host name or IP address, try:

{{ request.host.split(':')[0] }}

Alternatively, you could query the WSGI environment directly:

{{ request.environ['SERVER_NAME'] }}