Answers for "express server html file wtih js files"

9

send html file express

res.sendFile(path.join(__dirname + '/index.html'));
Posted by: Guest on March-05-2020
0

serve a file in express

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

app.use(express.static(__dirname + '/dist'))

app.get('/', (_, res) => {
    res.sendFile('index.html')
})

app.listen(3000)
Posted by: Guest on June-15-2021

Browse Popular Code Answers by Language