UNPKG

ibm-india-rajtgin

Version:

This is my IBM Oct training module

33 lines (29 loc) 1.08 kB
/** * Created by Raj on 10/25/2016. */ /** * Created by Raj on 10/25/2016. */ var http = require("http"); var port = 5566; var host = "localhost"; var indexpage = "<html><head><title>My application</title></head><body><h1>This is my Index Page </h1><a href='/about.html'>About Page</a> </body></html>" var aboutpage = "<html><head><title>My application</title></head><body><h1>This is my About Page </h1><a href='/index.html'>Home Page</a></body></html>" var server = http.createServer(function(request, response){ console.log("some request came in...."); response.writeHead(200,{ "Content-type" : "text/html" }) console.log(request.url); if(request.url == "/index.html"){ response.write(indexpage) }else if(request.url == "/about.html"){ response.write(indexpage) }else { response.write("<h1>Page not available</h1>"); } response.end(); }) server.listen(port,host,function(error){ console.log("server is running on http://" + host + ":" + port, error + " happend") })