//console.log ("Hello World");varHttp=require ("http");varServer=http.createserver (function(request,response) {console.log (Request.method); Console.log (Request.url); if(request.method=== "GET") {Response.setheader ("Content-type", "text/html"); Response.setheader ("Content-encoding", "UTF8");//UTF8 Encoding varHtml= "";//HTML code Switch(request.url) { Case"/": Case"/index.html": HTML= "//UTF8 Encoding"<title> title </title> ; Break; Case"/add.html": HTML= "//UTF8 Encoding"<title> title </title> ; Break; Case"/remove.html": HTML= "//UTF8 Encoding"<title> title </title> ; Break; Case"/find.html": HTML= "//UTF8 Encoding"<title> title </title> ; Break; Case"/edit.html": HTML= "//UTF8 Encoding"<title> title </title> ; Break; default: HTML= "//UTF8 Encoding"<title> title </title> ; Console.log ("Invalid Request URL:" +Request.url); }; Response.End (HTML); } response.end ();}); Server.listen (80);
Nodejs Use--Example 1