How to create a Http Server?

const http = require('http');

const requestListener = function (req, res) {
res.writeHead(200);
res.end('Hello, World!');
}

const server = http.createServer(requestListener);
server.listen(8080);

Suppose you have defined all yours apis inside app.js , then export it and use inside server.js :-

const http = require('http');const app = require(./app.js)  

const server = http.createServer(app);
server.listen(8080);

--

--

SimplifiedCoding

SimplifiedCoding

Graduated from IIT kanpur. I am blockchain developer with some expertise in NodeJS. Will try to explain everything in laymen terms.