express hosting static files

 

app.js file content

const express = require('express')
const app = express()

// 服务端口号
const port = 3000
// 利用 Express 托管静态文件
app.use(express.static('public'))

app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`)
})

Create index.html in the folder as follows:

<h1>你好</h1>

 

 

Guess you like

Origin blog.csdn.net/liuhao9999/article/details/115198759