-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (24 loc) · 765 Bytes
/
app.js
File metadata and controls
27 lines (24 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fs = require("fs");
const getIPAdress = require("./libs/utils");
// 引入express中间件
const express = require("express");
// 创建web服务器
const app = express();
const mdToHtml = require("./md");
mdToHtml();
fs.watchFile('./README.md', (cur, pre) => {
if (cur.mtime !== pre.mtime) {
mdToHtml()
console.info('README文件已更改!')
}
})
// 指定启动服务器到哪个文件夹
app.use('/example', express.static("./"));
// 启动服务器监听80端口
// const port = 3000;
const server = app.listen(9000, () => {
const port = server.address().port
console.log("web server runnin at:");
console.log(`Local: http://localhost:${port}/example`);
console.log(`Network: http://${getIPAdress.myHost}:${port}/example`);
});