-
Notifications
You must be signed in to change notification settings - Fork 0
/
preview.js
36 lines (31 loc) · 687 Bytes
/
preview.js
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
28
29
30
31
32
33
34
35
36
const path = require('path')
const express = require('express')
const app = express()
// 静态资源映射
// https://blog.csdn.net/weixin_45843676/article/details/125682723
app.use('/dist',express.static('./dist'))
// https://codeforgeek.com/render-html-file-expressjs/
app.get('/', function(req, res) {
res.sendFile(
path.join(__dirname, 'index.html')
)
})
const PORT = 5000
app.listen(PORT, () => {
const blank = ''.padStart(1)
console.log(
'\n',
blank,
'🚀🚀🚀',
'\x1b[32m',
'Express Server running at:\n',
'\x1b[0m'
)
console.log(
blank,
'> Local: ',
'\x1b[36m',
`http://localhost:${PORT}/`,
'\x1b[0m'
)
})