/** * Module dependencies. */ var express = require('express') , routes = require('./routes') , helloRoutes = require('./routes/helloworld'); var mongoose = module.exports = require('mongoose'); var db = mongoose.connect('mongodb://localhost/test'); var app = module.exports = express.createServer(); var visitCount =module.exports=0;
// Configuration app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade');//view엔진 두개? app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(__dirname + '/public')); }); app.configure('development', function(){ app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); }); app.configure('production', function(){ app.use(express.errorHandler()); }); app.get('/', routes.index); // Routes
app.get('/test', helloRoutes.TestList); //show sample List
app.get('/test/:id', helloRoutes.TestShowDetailPage); //show detail Page's Using REST app.post('/test/:id/edit', helloRoutes.TestUpdateLogic); //do Update Logic
app.get('/new', helloRoutes.TestShowNewTemplate); //show New Template page app.post('/new',helloRoutes.TestDoNewTemplate); //do New Template Insert Logic app.get('/test/:id/delete',helloRoutes.TestDoDelete); //do Delete Logic
app.listen(process.env.port || 3000); console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
'javascript 혁명' 카테고리의 다른 글
helloworld.js (0) | 2013.03.14 |
---|