반응형
라우팅은 애플리케이션 엔드 포인트(URI)의 정의, 그리고 URI가 클라이언트 요청에 응답하는 방식을 말합니다.
expressjs.com
Express 기본 라우팅
기본 라우팅 라우팅은 URI(또는 경로) 및 특정한 HTTP 요청 메소드(GET, POST 등)인 특정 엔드포인트에 대한 클라이언트 요청에 애플리케이션이 응답하는 방법을 결정하는 것을 말합니다. 각 라우트는 하나 이상의 핸들러 함수를 가질 수 있으며, 이러한 함수는 라우트가 일치할 때 실행됩니다. 라우트 정의에는 다음과 같은 구조가 필요합니다. app.METHOD(PATH, HANDLER) 여기서, app은 express의 인스턴스입니다. METHOD는
expressjs.com
var router = express.Router();
...
// 라우터 객체 등록
app.use('/', router);
Difference Between app.use() and router.use() in Express
I was just reading the documentation on express and found these two terms, app.use(); and router.use(); I know app.use(); is used in node for Mounting a middleware at a path, and we often use it i...
stackoverflow.com
router.route('/login').get(function(req, res) {
console.log('/login 패스 요청됨.');
res.render('login.ejs', {message: req.flash('loginMessage')});
});
..
app.get('/', function (req, res) {
res.send('GET request to the homepage');
});
blog.outsider.ne.kr
반응형
'IT > web' 카테고리의 다른 글
Node.js] 구글 패스포트로 사용자 인증 (0) | 2020.02.10 |
---|---|
Node.js] 플래쉬 메시지 (0) | 2020.02.08 |
Node.js] 사용자 인증 // 패스포트 모듈 (0) | 2020.02.07 |
Node.js ] 뷰 렌더링 // ejs, pug (0) | 2020.02.06 |
Node.js] config 설정파일 분리하기 (0) | 2020.02.04 |
댓글