mkdir /home/clychee/桌面/node
cd /home/clychee/桌面/node/
npm init
npm install express
新建index.js
const express = require('express')
const path = require('path')
const app = express()
app.use(express.static(path.join(__dirname, 'public')))
app.listen(8080, () => {
console.log('App listening at port 8080')
})
新建public目录,将访问的html文件放在public目录里.
网友评论