메뉴얼 사이트
- Application : http://expressjs.com/api.html#express
- Request : http://expressjs.com/api.html#req.params
- Response : http://expressjs.com/api.html#res.status
- Router : http://expressjs.com/api.html#router
- Middleware : http://expressjs.com/api.html#middleware.api
테스트 샘플자료 (자세한 내용은 위에 API 참조하면 방대함 정규식처리등 많음)
- var express = require('express'), http = require('http');
- var bodyParser = require('body-parser');
- var app = express();
- app.use(bodyParser());
- app.all('*', function( req, res, next){
- res.writeHead(200,{
- "Content-Type" : "text/plain"
- });
- next();
- });
- app.get("/", function( req, res){
- res.end("HOME DIR : /");
- });
- app.get("/test", function( req, res){
- res.end("HOME DIR : /test");
- });
- app.get("/params/:user", function( req, res){
- var sText = " Params : "+req.params.user; // OR req.param('user')
- sText += "\n GET : "+req.query.q; //search?q=test OR req.param('q')
- sText += "\n POST : "+req.param('name'); //POST name=tobi
- //sText += "Cookie : "+req.cookies.name; // Cookie: name=tj
- sText += "\n ip : "+req.ip; // req.ips When "trust proxy" is `true`, parse the "X-Forwarded-For"
- res.end(sText);
- });
- app.get("*", function( req, res){
- res.end("NOT PAGE");
- });
- http.createServer(app).listen(80, '127.0.0.1');
- console.log('HTTP URL : http://127.0.0.1:80/');