nodejs-simple-webserver

Migrate from https://cmakerhk.wordpress.com/2018/10/31/nodejs-simple-webserver/


var http = require('http');

//create a server object
http.createServer(
  function(req, res){
    res.writeHead(200,{'Content-Type':'text/html'});
    res.write('Hello World'); //write the response to the client
    res.end(); //end the response
  }
).listen(8080); // the server object listen on port 8080

http.createServer().listen(8080)

when you run that command on the node shell, it will create a server on local host and print hello world.

or node demo_http.js

The Query String

http://localhost:8080/summer
^——- the /summer is the query string