How to create a simple server page application on node
Here are the steps to create server using node
We need to create a http variable
1. var http = require("http");
2. create server with request and respose
3.Send request and listen on a port
4.get log on that port .
Here is an example
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8082);
// Console will print the message
console.log('Server running at http://127.0.0.1:8082/');
Type http://localhost:8082/
browser out : Hello World
![How to create a simple server page application on node](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiznsW5g8Estgm4oqqpWvRH3dHHswtfpQqvULeoYmxeVSckGNS4OA3U7z1EkHC15kCwqJvkM49RJw2Varh4bAcNBA_hD92njSMpmO6be3UfjlPVvhI6fn1dNAdXtbuUAokGDAMYB5tF3LA/s72-w588-c-h345/Screenshot+2020-10-02+at+4.22.44+PM.png)
No comments:
Add your comment