1. http 모듈 살펴보기
const http = require("http");
console.log(http.STATUS_CODES);
console.log(http.METHODS);
![](https://velog.velcdn.com/images/fkstndnjs/post/aaf886c1-9fe7-4282-aad4-5ce738e03c48/image.png)
2. 간단한 서버 만들어보기
const http = require("http");
const server = http.createServer((req, res) => {
console.log("Server On...");
console.log(req.headers);
console.log(req.httpVersion);
console.log(req.method);
console.log(req.url);
res.write("Hello");
res.end();
});
server.listen(8080);
![](https://velog.velcdn.com/images/fkstndnjs/post/9d842609-b5d9-415c-a832-b0689d04f9c0/image.png)
![](https://velog.velcdn.com/images/fkstndnjs/post/d8ececd5-6a9a-4dad-89be-9f8dfa521e3f/image.png)
![](https://velog.velcdn.com/images/fkstndnjs/post/5118d450-b85a-4362-9bab-8ab5154e472c/image.png)
3. 라우팅
const http = require("http");
const server = http.createServer((req, res) => {
if (req.url === "/") {
res.write("HOME");
} else if (req.url === "/test") {
res.write("TEST");
} else {
res.write("NOT FOUND");
}
res.end();
});
server.listen(8080);
![](https://velog.velcdn.com/images/fkstndnjs/post/1485162d-e56b-4053-ae17-dd3a53903bf3/image.png)
![](https://velog.velcdn.com/images/fkstndnjs/post/43b5b685-fb93-4690-866f-6a1f91134301/image.png)
![](https://velog.velcdn.com/images/fkstndnjs/post/81da178f-d16e-4e3c-8d44-25b4603c49ed/image.png)