/ Published in: JavaScript
Node create server with request response
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var http = require("http"); var path = require("path"), var url = require("url"), var server = http.createServer(function(request, response) { var method = request.method; var my_path = url.parse(request.url).pathname; var full_path = path.join('/delete',my_path); response.writeHead(200, {"Content-Type": "text/html"}); response.write("<!DOCTYPE "html">"); response.write("<html>"); response.write("<head>"); response.write("<title>Hello World Page</title>"); response.write("</head>"); response.write("<body>"); response.write("Hello World!"); response.write("</body>"); response.write("</html>"); response.end(); }); server.listen(80); console.log("Server is listening");