what does http createserver do

Solutions on MaxInterview for what does http createserver do by the best coders in the world

showing results for - "what does http createserver do"
Isabel
16 May 2020
1var http = require('http'); // Import Node.js core module
2
3var server = http.createServer(function (req, res) {   //create web server
4    if (req.url == '/') { //check the URL of the current request
5        
6        // set response header
7        res.writeHead(200, { 'Content-Type': 'text/html' }); 
8        
9        // set response content    
10        res.write('<html><body><p>This is home Page.</p></body></html>');
11        res.end();
12    
13    }
14    else if (req.url == "/student") {
15        
16        res.writeHead(200, { 'Content-Type': 'text/html' });
17        res.write('<html><body><p>This is student Page.</p></body></html>');
18        res.end();
19    
20    }
21    else if (req.url == "/admin") {
22        
23        res.writeHead(200, { 'Content-Type': 'text/html' });
24        res.write('<html><body><p>This is admin Page.</p></body></html>');
25        res.end();
26    
27    }
28    else
29        res.end('Invalid Request!');
30
31});
32
33server.listen(5000); //6 - listen for any incoming requests
34
35console.log('Node.js web server at port 5000 is running..')
36
queries leading to this page
how to create node js serverhttp server module nodejshttp createserver 28 29 node jscreate server http nodejshttp createserver 28app 29example of http createserver 28app 29get method out of http createserverhttp createserver resnodejs http createserverwhat is a server in node jshttp module node jsnode js simple web server exampleconst http 3d require 28 27http 27 29http createserver exampleusing http createserver inside app gethttp createserverconst server 3d http createserver 28 29server createserver 28 29var server 3d http createserver 28app 29 3b 3fhttp createserver nodejshttp createserver res andjs serverhttp createserver function 7b createserver 7d from 27http 27create node js serverhttp createserver 28 29http createserver usewhat is http createserver 28app 29http createserver apphttp createserver 28http createserver nodejs examplecreate server node jsweb server using node jshttp server nodecreateserver nodejsnode js http modulehttp createserver 28 29 3b nhttpswhat is http createserverhttp server js codenode js webservercreate nodejs web servernode js create servernodejs http servernode js http serverhttp server node js what does http createserver dohttp createserver nodejscreate web server jshttp server nodejssimple http createserverhttp createserver listenhttp createservernode serverhttp createserver expressnode http create serverjs http createserverhttp server for node jsnode http createservernode http serverwhy use http createservernode http createserversimple nodejs web servercreate web server node jsconst server 3d http createserver 28app 29how to createserver http const server 3d http createserverhttp createserver optionshttp server nodejshttp createserver 28 29 deperecatedhttps createservernodejs create web servermake server with node jshttp createserver nodejavascript http createserverhttp createserver 28 29 what does the request in http createserver dohttp createserver nodewhat does http createserver do