{ res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello!"); }); server.listen(PORT, () => console.log(`Listening on port ${PORT}`));"> { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello!"); }); server.listen(PORT, () => console.log(`Listening on port ${PORT}`));"> { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello!"); }); server.listen(PORT, () => console.log(`Listening on port ${PORT}`));">
const http = require("http");

const PORT = 3000;

const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end("Hello!");
});

server.listen(PORT, () => console.log(`Listening on port ${PORT}`));

<aside> 💡

http.createServer(*requestListener*);

</aside>

CreateServer 메소드

server 객체

RequestListener 함수

req

Untitled

res