Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get the running server URL

Tags:

django

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.

like image 1000
Mark Waugh Avatar asked Apr 12 '12 07:04

Mark Waugh


People also ask

How do I find my server URL Linux?

To check the current nameservers (DNS) for any domain name from a Linux or Unix/macOS command line: Open the Terminal application. Type host -t ns domain-name-com-here to print the current DNS servers of a domain. Another options is to run dig ns your-domain-name command.

How do I find my Django server URL?

Run the following command to start the Django server. Execute the following URL from the browser to display the domain name of the current URL. The geturl1() function will be called for this URL that will send the domain name to the index. html file.


1 Answers

request.build_absolute_uri('/') 

or you could try

import socket socket.gethostbyname(socket.gethostname()) 
like image 90
Hedde van der Heide Avatar answered Sep 25 '22 23:09

Hedde van der Heide