how to make a local server using node js
// first you need to install node js
// get the http to create a free local host server running live
const http = require('http');
// you got the http and now we need to setup some stuff
// to make a local host site we need to define it at a port for 4 numbers.
// we will get 2 things from the site request (req) and response (res).
const server = http.createServer((req,res) => {
if (req.url === '/') { // this means if person will search for example localhost:9182/
res.write('hello this is some text');
res.end();
}
if (req.url === '/anotherPage') {
res.write('you entered another page'); // this /some text means another site or page of the website.
res.end(); // this end function means we dont want to make anything else than this
}
});
server.listen(9999); // you can write any port instead of 9999
// then server will open like localhost:9999 or your number instead of 9999