What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-05 14:49:03
render html in node js
let http = require('http'); let fs = require('fs'); let handleRequest = (request, response) => { response.writeHead(200, { 'Content-Type': 'text/html' &nbs... Add solution -
Javascript 2021-10-03 20:04:04
serving html and css with node js
// HTTP Module for Creating Server and Serving Static Files Using Node.js // Static Files: HTML, CSS, JS, Images // Get Complete Source Code from Pabbly.com var http = require('http'); var fs = require('fs'); var path = require('path'); http.createServe... Add solution -
Javascript 2021-09-28 16:32:05
SERVER PORT NODE.JS
const http = require('http'); const hostname = '127.0.0.1'; const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World'); }); server.listen(port, ... Add solution -
Javascript 2021-09-11 18:31:02
node js send javascript
const fs = require("fs"); const hostname = "127.0.0.1"; const port = 3000; // use createReadStream instead to save memory const index = fs.readFileSync("index.html"); const java = fs.readFileSync("javascript.js"); ... Add solution -
Other 2021-09-05 10:21:02
node js creating server
const http = require('http'); const hostname = '127.0.0.1'; const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World'); }); server.listen(port, ... Add solution -
Html 2021-09-05 08:07:05
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) Add solution -
Javascript 2021-09-03 16:42:02
nodejs cluster example
const cluster = require('cluster'); const http = require('http'); const numCPUs = require('os').cpus().length; if (cluster.isMaster) { console.log(`Master ${process.pid} is running`); // Fork workers. for (let i = 0; i < numCPUs; i++) { clu... Add solution -
Javascript 2021-08-31 19:14:01
Create a server which serves at port 3000 and with node.js command prompt
// app.js const http = require('http'); // Create an instance of the http server to handle HTTP requests let app = http.createServer((req, res) => { // Set a response type of plain text for the response res.writeHead(200, {'Content-Type': 'te... Add solution -
Javascript 2021-08-28 06:44:02
node cluster
const cluster = require('cluster'); const http = require('http'); const numCPUs = require('os').cpus().length; if (cluster.isMaster) { console.log(`Master ${process.pid} is running`); // Fork workers. for (let i = 0; i < numCPUs; i++) { clu... Add solution