0

I’m trying to find the location of the URL parameter /info/getips/ in GetJSON function. Below is my code. I am using ubuntu. this is a Djongo project :

File :Board.js

dashboard.getIps = function() {
  $.getJSON('/info/getips/', function(data) {


    var psTable = $("#get_ips").dataTable({
      aaData: data,
      aoColumns: [{
          sTitle: "INTERFACE"
        },
        {
          sTitle: "MAC ADDRESS"
        },
        {
          sTitle: "IP ADDRESS"
        },
        {
          sTitle: "IP ADDRESS",
          sDefaultContent: "unavailable"
        }
      ],
      bPaginate: false,
      bFilter: true,
      sDom: "lrtip",
      bAutoWidth: false,
      bInfo: false
    }).fadeIn();
    $filterPs.on("keyup", function() {
      psTable.fnFilter(this.value);
    });
  });
};

File : view.py

def get_ipaddress():
"""
Get the IP Address
"""
data = []
try:
    eth = os.popen("ip addr | grep LOWER_UP | awk '{print $2}'")
    iface = eth.read().strip().replace(':', '').split('\n')
    eth.close()
    del iface[0]

    for i in iface:
        pipe = os.popen("ip addr show " + i + "| awk '{if ($2 == \"forever\"){!$2} else {print $2}}'")
        data1 = pipe.read().strip().split('\n')
        pipe.close()
        if len(data1) == 2:
            data1.append('unavailable')
        if len(data1) == 3:
            data1.append('unavailable')
        data1[0] = i
        data.append(data1)

    ips = {'interface': iface, 'itfip': data}

    data = ips

except Exception as err:
    data = str(err)

return data

def getips(request):
"""
Return the IPs and interfaces
"""
try:
    get_ips = get_ipaddress()
except Exception:
    get_ips = None

data = json.dumps(get_ips['itfip'])
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.write(data)
return response

File index.html

  <div class="span6">
       <div class="widget widget-table action-table">
        <div class="widget-header"> <i class="fa fa-level-up"></i>
          <h3>IP Adresses</h3><i class="fa fa-minus"></i>
          <div id="refresh-ip">
          </div>
        </div>
        <!-- /widget-header -->
        <div class="widget-content">
    <table id="get_ips" class="table table-hover table-condensed table-bordered">
    </table>
        </div>
        <!-- /widget-content -->
      </div>
      <!-- /widget -->
     </div>

$(function pageLoad() {

board.getIps();
});

1 Answers1

1

mean the absolute path on the file system tree

Since the relative URL starts with a /, you go to the root: You take the scheme (sometimes called protocol), hostname, and port (if any) of the page in which this URL is being used, and add the URL to it. So for instance, if the page is at https://example.com/some/path/to/the/file.html, you'd take the scheme (https) and hostname (example.com) (there's no port in that example) and get https://example.com/info/getips/. If it were http://blah.example.com:8080/index.html you'd take the scheme, hostname, and port: http://blah.example.com:8080/info/getips/.

The only way to know where that is in the server's file system is to look at the web server configuration to know what it does with that URL, which can be anything although often (but not at all always) it's that there's a base directory for the host and then the rest of the URL maps to subdirectories and such therein.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • thanks for the response but the file still unfounded , tired all possible Linux commands to search files nut no success , i just added the rest of the the code .this is a Django python project , and all the files are loaded properly . –  Sep 29 '19 at 18:14