𝗗𝗮𝘆 𝟯𝟱 𝗼𝗳 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗠𝗘𝗥𝗡 𝗦𝘁𝗮𝗰𝗸

I built my first native web server today.

In my Node.js course, I moved past local scripts. My code no longer runs and stops. Now, the server stays active. It listens for connections from the internet.

I learned how computers communicate over a network. Here is what I learned:

The http Module I used the native http utility to handle data. I used http.createServer() to start the server. This function uses two arguments:

The listen Method A server needs a specific port to communicate. I set my server to listen on port 8000. This acts as a gateway for incoming requests.

Code implementation:

const http = require("http");

const server = http.createServer((req, res) => { res.end("Hello from my Day 35 custom server!"); });

server.listen(8000, () => { console.log("Server is live on port 8000"); });

Source: https://dev.to/ali_hamza_589ec7b3eb6688d/day-35-of-learning-mern-stack-ldn