Express 시작 (1)
6975 단어 사이트 개발
기사 목록
기본 서버 구축
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('this is the homepage');
console.log('this is the homepage');
});
app.listen(3000);
console.log('listening to port 3000');
라우팅 매개변수
var express = require('express');
var app = express();
app.get('/profile/:id/user/:name', function(req, res){//:id , id
console.log(req.params);
res.send('You will see a profile with the id of ' + req.params.id);
});
app.get('/ab?cd', function(req, res){//
res.send(' /ab?cd');
});
app.listen(3000);
console.log('listening to port 3000');
질의 문자열
//http://127.0.0.1:3000/?find=hot req.query {find : 'hot'}
app.get('/', function(req, res){
console.dir(req.query["find"]);
res.send('here' + res.query.id);
});