Answers for "how to make a node.js server on html"

2

server html page using nodejs

const http = require('http')
const fs = require('fs')

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'content-type': 'text/html' })
  fs.createReadStream('index.html').pipe(res)
})

server.listen(process.env.PORT || 3000)
Posted by: Guest on July-17-2021

Code answers related to "how to make a node.js server on html"

Browse Popular Code Answers by Language