This commit is contained in:
32
index.html
Normal file
32
index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.11.0/axios.min.js"></script>
|
||||
<script>
|
||||
const IP = async () => {
|
||||
let { data } = await axios.get('http://192.168.31.100:9900/ip');
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
const main = async () => {
|
||||
let res = await IP()
|
||||
console.log(res);
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
7
index.js
7
index.js
@@ -5,6 +5,13 @@ const { port, command } = require('./config');
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
|
||||
app.use((req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Methods', 'GET, POST');
|
||||
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
|
||||
next();
|
||||
});
|
||||
|
||||
app.get('/ip', async (req, res) => {
|
||||
let output = execSync(command, { encoding: "utf8" });
|
||||
res.json(await ip.parseNetworkInfo(output))
|
||||
|
||||
Reference in New Issue
Block a user