diff --git a/index.html b/index.html deleted file mode 100644 index 9307514..0000000 --- a/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Document - - - - - - - - - \ No newline at end of file diff --git a/index.js b/index.js index ae27aa5..39c586a 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,10 @@ const { port, command } = require('./config'); const express = require('express') const app = express() +// 配置静态文件目录 +// 这会将项目中的public文件夹设置为静态资源目录 +app.use(express.static(path.join(__dirname, 'public'))); + app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET, POST'); @@ -17,6 +21,11 @@ app.get('/ip', async (req, res) => { res.json(await ip.parseNetworkInfo(output)) }) +app.get('/', async (req, res) => { + // 使用sendFile方法发送HTML文件 + res.sendFile(path.join(__dirname, 'public', 'index.html')); +}) + app.listen(port, () => { console.log(`app listening on port: http://127.0.0.1:${port}`) }) diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..62f9643 --- /dev/null +++ b/public/index.html @@ -0,0 +1,113 @@ + + + + + + + NAS IPV6查询 + + + + +
+ +
+ + + + + + \ No newline at end of file