How can i get the running server URL

django

Solution

request.build_absolute_uri('/')

or you could try

import socket
socket.gethostbyname(socket.gethostname())

Problem

When i run the server it shows me a message http://127.0.0.1:8000/. I want to get the url in code. I dont have request object there.

Original source