我在哪里可以找到 getJSON 中 URL 路径的位置
where can i find the location of the path of URL in getJSON
我试图在 GetJSON 函数中找到 URL 参数 /info/getips/
的位置。
下面是我的代码。我正在使用 ubuntu。这是一个 Djongo 项目:
文件: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);
});
});
};
文件:view.py
def get_ipaddress():
"""
Get the IP Address
"""
data = []
try:
eth = os.popen("ip addr | grep LOWER_UP | awk '{print }'")
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 ( == \"forever\"){!} else {print }}'")
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
文件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>
$(函数页面加载() {
board.getIps();
});
mean the absolute path on the file system tree
由于相对 URL 以 /
开头,您转到根目录:您获取页面的方案(有时称为协议)、主机名和端口(如果有)正在使用此 URL,并向其添加 URL。因此,例如,如果页面位于 https://example.com/some/path/to/the/file.html
,您将采用方案 (https
) 和主机名 (example.com
)(该示例中没有端口)并得到 https://example.com/info/getips/
.如果是 http://blah.example.com:8080/index.html
,您将采用方案、主机名和端口:http://blah.example.com:8080/info/getips/
.
了解它在服务器文件系统中的位置的唯一方法是查看 Web 服务器配置以了解它对 URL 的作用,它可以是 任何东西 虽然经常(但不是 完全 总是)这是主机有一个基本目录,然后 URL 的其余部分映射到子目录等。
我试图在 GetJSON 函数中找到 URL 参数 /info/getips/
的位置。
下面是我的代码。我正在使用 ubuntu。这是一个 Djongo 项目:
文件: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);
});
});
};
文件:view.py
def get_ipaddress():
"""
Get the IP Address
"""
data = []
try:
eth = os.popen("ip addr | grep LOWER_UP | awk '{print }'")
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 ( == \"forever\"){!} else {print }}'")
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
文件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>
$(函数页面加载() {
board.getIps();
});
mean the absolute path on the file system tree
由于相对 URL 以 /
开头,您转到根目录:您获取页面的方案(有时称为协议)、主机名和端口(如果有)正在使用此 URL,并向其添加 URL。因此,例如,如果页面位于 https://example.com/some/path/to/the/file.html
,您将采用方案 (https
) 和主机名 (example.com
)(该示例中没有端口)并得到 https://example.com/info/getips/
.如果是 http://blah.example.com:8080/index.html
,您将采用方案、主机名和端口:http://blah.example.com:8080/info/getips/
.
了解它在服务器文件系统中的位置的唯一方法是查看 Web 服务器配置以了解它对 URL 的作用,它可以是 任何东西 虽然经常(但不是 完全 总是)这是主机有一个基本目录,然后 URL 的其余部分映射到子目录等。