-
[Node.js] Express 서버 구축WEB/NodeJS 2022. 9. 18. 14:02
앞 글에서 환경설정한대로 실행할 때는 터미널에 npm run dev 입력
index.js
import express from "express"; const PORT = 4000; // 서버 포트 번호 const app = express(); // GET 요청을 통해 설정한 url 입력 및 메시지를 출력 // get('url 주소', request, response 인자를 가지는 콜백 함수) 형태 app.get("/", (req, res) => res.send("하잉")); //라우터에 대한 요청에 "하잉"으로 응답 const handelListening = () => console.log("서버 시작 " + `http://localhost:${PORT}`); app.listen(PORT, handelListening); // app.listen() 함수를 사용하여 서버 실행
728x90'WEB > NodeJS' 카테고리의 다른 글
[Node.js] Node.js - CRUD(MySql) (0) 2022.09.20 [Node.js] Node.js - MySql 연동 (0) 2022.09.19 [Node.js] Node.js CRUD(DB 연결X) (0) 2022.09.18 [Node.js] Pug partials (0) 2022.09.17 [Node.js] node.js에서 pug 연결 (0) 2022.09.15