Kibble
0
Q:

node.js web server

const http = require('http');
const port = 3000;

console.log(`Server is running on port ${port}`);
http.createServer(function(req, res){
	res.writeHead(200, {'Content-Type': 'text/html'});
    res.write('Write some HTML here...');
    res.end();
}).listen(port);

// save this as server.js
// you have to download node.js
// open terminal or command prompt
// type node server.js
// find your server at http://localhost:3000
// to end the server, go to that terminal and press ctrl+c
2
// code by VARSHITH REDDY SATTI
// to create a server in node.js you should.
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write("write html code to display you test")
  res.end();
}).listen(8080);
// save this as httpServer.js
// run this by typing node httpServer.js in the command line
// to acess your server got to http://localhost:8080
2
var http = require('http');

//create a server object:
http.createServer(function (req, res) {
  res.write('Hello World!'); //write a response to the client
  res.end(); //end the response
}).listen(8080); //the 
2

New to Communities?

Join the community