Answers for "express server file"

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
1

app.use public

app.use(express.static('public'))
app.use(express.static('files'))
Posted by: Guest on April-02-2020

Browse Popular Code Answers by Language