[ Prev ]
2017-05-10

-- May 10 In-Class Exercise
 Name: Pei Liu
 Student ID: 010200255
 
 === config.js =========
 
 
 module.exports = {
     'foo' : 'this is foo',
     'goo' : 'this is goo'
 }
 
 ===== app.js ===========
 
 var express = require('express');
 var path = require('path');
 var logger = require('morgan');
 var cookieParser = require('cookie-parser');
 var bodyParser = require('body-parser'); 
 
 var index = require('./routes/index');
 var users = require('./routes/users');
 var config = require('./config.js');
 
 var app = express();
 
 // view engine setup
 app.set('views', path.join(__dirname, 'views'));
 app.set('view engine', 'jade');
 
 app.use(logger('dev'));
 app.use(bodyParser.json());
 app.use(bodyParser.urlencoded({ extended: false }));
 app.use(cookieParser());
 app.use(express.static(path.join(__dirname, 'public')));
 
 app.use('/', index);
 
 app.use(function(req, res, next) {
     console.log('your IP Address: 'req.ip + " and route: " + req.path)
     next()
 });
 
 app.get('/*foo*', function(req, res) {
     res.render('index', {'msg' : config.foo});
 });
 app.get('/', function(req, res) {
     res.render('index', {'msg' : config.goo});
 });
 
 app.get('/*', function(req, res) {
     res.render('index', {'msg' : config.goo});
 });
 
Name: Pei Liu Student ID: 010200255 === config.js ========= module.exports = { 'foo' : 'this is foo', 'goo' : 'this is goo' } ===== app.js =========== var express = require('express'); var path = require('path'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var index = require('./routes/index'); var users = require('./routes/users'); var config = require('./config.js'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', index); app.use(function(req, res, next) { console.log('your IP Address: 'req.ip + " and route: " + req.path) next() }); app.get('/*foo*', function(req, res) { res.render('index', {'msg' : config.foo}); }); app.get('/', function(req, res) { res.render('index', {'msg' : config.goo}); }); app.get('/*', function(req, res) { res.render('index', {'msg' : config.goo}); });

-- May 10 In-Class Exercise
 Name: Luis Otero
 var express = require('express');
 var path = require('path');
 var config = require(path.join(__dirname, 'config'));
 var app = express();
 var log = function(req, res, next){
	req.logger_name = "IP logger";
	console.log(req.ip);
	next();
 };
 
 app.use(log);
 app.get('/*foo*', function(req, res){
	res.send("<!DOCTYPE html><html><head><title>"+config.foo+"</title></head><body><h1>"+config.foo+"</h1></body>
 </html>");
 });
 app.get('/', function(req, res){
	res.send("<!DOCTYPE html><html><head><title>"+config.goo+"</title></head><body><h1>"+config.goo+"</h1></body>
 </html>");
 });
 app.get('/*', function(req, res){
	res.send("<!DOCTYPE html><html><head><title>"+config.goo+"</title></head><body><h1>"+config.goo+"</h1></body>
 </html>");
 });
 app.listen(8888, function(){
	console.log("Server is running!");
 });
Name: Luis Otero var express = require('express'); var path = require('path'); var config = require(path.join(__dirname, 'config')); var app = express(); var log = function(req, res, next){ req.logger_name = "IP logger"; console.log(req.ip); next(); }; app.use(log); app.get('/*foo*', function(req, res){ res.send("<!DOCTYPE html><html><head><title>"+config.foo+"</title></head><body><h1>"+config.foo+"</h1></body> </html>"); }); app.get('/', function(req, res){ res.send("<!DOCTYPE html><html><head><title>"+config.goo+"</title></head><body><h1>"+config.goo+"</h1></body> </html>"); }); app.get('/*', function(req, res){ res.send("<!DOCTYPE html><html><head><title>"+config.goo+"</title></head><body><h1>"+config.goo+"</h1></body> </html>"); }); app.listen(8888, function(){ console.log("Server is running!"); });

-- May 10 In-Class Exercise
Madula Ramabathiran

 app.js

 var express = require('express');
 var config = require('config.js');
 var app = express();
 app.get('/*foo*', function (req, res) {
    res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\
 <body><div>' + config.foo + '</div></body></html>');
 });
 app.get('/', function (req, res) {
    res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\
 <body><div>' + config.goo + '</div></body></html>');
 });
 app.get('*', function (req, res) {
    res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\
 <body><div>' + config.goo + '</div></body></html>');
 });
 var logs = function (req, res, next) {
    console.log("IP: " + req.ip);
    next(); // call the next handler
 };
 app.use(logs);
 app.listen(8888, function () {
    console.log('Server up!');
 });

 config.js

 var config = {
    'foo': 'foo',
    'goo': 'goo'
 };
 module.exports = config;
(Edited: 2017-05-10)
Madula Ramabathiran ---- ---- app.js ---- var express = require('express'); var config = require('config.js'); var app = express(); app.get('/*foo*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\ <body><div>' + config.foo + '</div></body></html>'); }); app.get('/', function (req, res) { res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\ <body><div>' + config.goo + '</div></body></html>'); }); app.get('*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>March 10 Exercise</title></head>\n\ <body><div>' + config.goo + '</div></body></html>'); }); var logs = function (req, res, next) { console.log("IP: " + req.ip); next(); // call the next handler }; app.use(logs); app.listen(8888, function () { console.log('Server up!'); }); ---- config.js ---- var config = { 'foo': 'foo', 'goo': 'goo' }; module.exports = config;

-- May 10 In-Class Exercise
Name: Nelson Dornelas

--> config.js:
var config = {
   "foo" : "foo",
   "goo" : "goo",
} module.exports = config;


--> index.ejs
<!DOCTYPE html> <html> <head>
  <title>May 10 In-Class Assignment</title>
</head> <body>
  <div><%=content%></div>
</body> </html>


--> app.js
var config = require('./config'); var path = require('path'); var express = require('express'); var app = express();
app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs');
var logger = function(req, res, next){
   console.log("Request IP: " + req.ip + "\n Route: " + req.path);
   next();
} app.use(logger);
app.get('/*foo*', function(req, res) {
  res.render('index', { 'content': config.foo});
});
app.get('/', function(req, res) {
  res.render('index', { 'content' : config.goo});
});
app.get('/*', function(req, res) {
  res.render('index', { 'content' : config.goo});
});
app.listen(8888, function() {
  console.log('Server is up at port 8888!');
});
(Edited: 2017-05-10)
Name: Nelson Dornelas <br><br> --> config.js: <br> var config = { "foo" : "foo", "goo" : "goo", } module.exports = config; <br> ---- <br> --> index.ejs <br> <!DOCTYPE html> <html> <head> <title>May 10 In-Class Assignment</title> </head> <body> <div><%=content%></div> </body> </html> <br> ---- <br> --> app.js <br> var config = require('./config'); var path = require('path'); var express = require('express'); var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); var logger = function(req, res, next){ console.log("Request IP: " + req.ip + "\n Route: " + req.path); next(); } app.use(logger); app.get('/*foo*', function(req, res) { res.render('index', { 'content': config.foo}); }); app.get('/', function(req, res) { res.render('index', { 'content' : config.goo}); }); app.get('/*', function(req, res) { res.render('index', { 'content' : config.goo}); }); app.listen(8888, function() { console.log('Server is up at port 8888!'); });

-- May 10 In-Class Exercise
Name: Tanusan Rajmohan
 var express = require('express');
 var path = require('path');
 var config = require(path.join(__dirname, 'config'));
 var app = express();
  
 var logger = function (req, res, next) {
 	console.log("ip: " + req.ip);
 	next()
 }
 app.use(logger);
 
 app.get('/*foo*', function(req, res) {
  	res.send('<!DOCTYPE html><html><head><title>In Class Exercise 12</title></head><body><h1>' + config.foo + '</h1></body></html>')
 })
 
 app.get('*', function(req, res) {
 	res.send('<!DOCTYPE html><html><head><title>In Class Exercise 12</title></head><body><h1>' + config.goo +'</h1></body></html>')
 })
 
 app.listen(8888, function () {
 	console.log('Server up!')
 })
'''Name: ''' Tanusan Rajmohan var express = require('express'); var path = require('path'); var config = require(path.join(__dirname, 'config')); var app = express(); var logger = function (req, res, next) { console.log("ip: " + req.ip); next() } app.use(logger); app.get('/*foo*', function(req, res) { res.send('<!DOCTYPE html><html><head><title>In Class Exercise 12</title></head><body><h1>' + config.foo + '</h1></body></html>') }) app.get('*', function(req, res) { res.send('<!DOCTYPE html><html><head><title>In Class Exercise 12</title></head><body><h1>' + config.goo +'</h1></body></html>') }) app.listen(8888, function () { console.log('Server up!') })

-- May 10 In-Class Exercise
  Mohnish Kadakia
  app.js
 var express = require('express');
 var config = require('config.js');
 var app = express();
app.get('/*foo*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>In class Exercise</title></head><body>' + config.foo + '</body></html>')
})
app.get('*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>In class Exercise</title></head><body>' + config.goo + '</body></html>')
})
var logs = function (req, res, next) {
    console.log(req.ip);
    next(); 
 }
 app.use(logs);
 
 app.listen(8888, function () {
    console.log('server is running');
 });
Config.js
var config = {
	foo: 'foo',
	goo: 'goo'
} module.exports = config;
Mohnish Kadakia app.js var express = require('express'); var config = require('config.js'); var app = express(); app.get('/*foo*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>In class Exercise</title></head><body>' + config.foo + '</body></html>') }) app.get('*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>In class Exercise</title></head><body>' + config.goo + '</body></html>') }) var logs = function (req, res, next) { console.log(req.ip); next(); } app.use(logs); app.listen(8888, function () { console.log('server is running'); }); Config.js var config = { foo: 'foo', goo: 'goo' } module.exports = config;

-- May 10 In-Class Exercise
saira montermoso
var express = require('express'); var app = express(); var config = require('./config');
app.set('views', './views'); app.set('view engine', 'ejs');
var logger = function(req, res, next) {
    console.log("IP address: " + req.ip);
    next()
} app.use(logger);
app.get('/*foo*', function(req, res) {
    res.render('index', {'FOO':config.foo});
});
app.get('*', function(req, res) {
    res.render('index', {'GOO':config.goo});
});
app.listen(8888, function() {
     console.log('Server up!')
})
saira montermoso var express = require('express'); var app = express(); var config = require('./config'); app.set('views', './views'); app.set('view engine', 'ejs'); var logger = function(req, res, next) { console.log("IP address: " + req.ip); next() } app.use(logger); app.get('/*foo*', function(req, res) { res.render('index', {'FOO':config.foo}); }); app.get('*', function(req, res) { res.render('index', {'GOO':config.goo}); }); app.listen(8888, function() { console.log('Server up!') })

-- May 10 In-Class Exercise
var express = require('express');
var app = express();
var config = require('./config');
var log= function(req, res, next){
	console.log(req.ip + " -> " + req.path)
	next() 
} app.use(log); app.get('/*foo*', function(req, res){
	res.send('<!DOCTYPE html><html><head><title>in class Excercise</title></head><body>' + config.foo + '</body></html>')
}) app.get('*', function(req, res){
	res.send('<!DOCTYPE html><html><head><title>in class Excercise</title></head><body>' + config.goo + '</body></html>')
}) app.listen(8888, function () {
    console.log('Server up!')
})
var express = require('express'); var app = express(); var config = require('./config'); var log= function(req, res, next){ console.log(req.ip + " -> " + req.path) next() } app.use(log); app.get('/*foo*', function(req, res){ res.send('<!DOCTYPE html><html><head><title>in class Excercise</title></head><body>' + config.foo + '</body></html>') }) app.get('*', function(req, res){ res.send('<!DOCTYPE html><html><head><title>in class Excercise</title></head><body>' + config.goo + '</body></html>') }) app.listen(8888, function () { console.log('Server up!') })

-- May 10 In-Class Exercise
Yitao Zhao
 var config = {
    "foo": "foo",
    "goo": "goo",
 }
 module.exports = config;
 var express = require('express');
 var config = require('./config');
 var app = express();
 
 var logger = function (req, res, next) { 
  console.log(req.ip);
  next()
 }
 app.use(logger);
 app.get('/*foo*', function(req, res) {
  res.send('<!DOCTYPE html><html><head><title>InClassExercise</title>   
  </head><body>' + config.foo + '</body></html>')
  })
 app.get('*', function(req, res) {
 res.send('<!DOCTYPE html><html><head><title>InClassExercise</title> 
 </head><body>' + config.goo +'</body></html>')
 })
 app.listen(8888, function () {
    console.log('Server up!')
 })
Yitao Zhao var config = { "foo": "foo", "goo": "goo", } module.exports = config; var express = require('express'); var config = require('./config'); var app = express(); var logger = function (req, res, next) { console.log(req.ip); next() } app.use(logger); app.get('/*foo*', function(req, res) { res.send('<!DOCTYPE html><html><head><title>InClassExercise</title> </head><body>' + config.foo + '</body></html>') }) app.get('*', function(req, res) { res.send('<!DOCTYPE html><html><head><title>InClassExercise</title> </head><body>' + config.goo +'</body></html>') }) app.listen(8888, function () { console.log('Server up!') })

-- May 10 In-Class Exercise
Name: Harita Shroff
  • ***********config.js************************************ var config = {
    	foo: 'foo',
    	goo: 'goo'
    
} module.exports = config;
  • **********************app.js******************************************
var config = require('./config') var express = require('express') var app = express()
var log = function (req, res, next) {
	console.log(req.ip + " --> " + req.path)
	next()
}; app.use(log);
app.get('/*foo*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>In class exercise 10th May, 2017</title></head><body>' + config.foo + '</body></html>')
});
app.get('*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>In class exercise 10th May, 2017</title></head><body>' + config.goo + '</body></html>')
});
app.listen(8888, function () {
	console.log('Server listening on port 8888!')
});
(Edited: 2017-05-10)
Name: Harita Shroff ************config.js************************************ var config = { foo: 'foo', goo: 'goo' } module.exports = config; ***********************app.js****************************************** var config = require('./config') var express = require('express') var app = express() var log = function (req, res, next) { console.log(req.ip + " --> " + req.path) next() }; app.use(log); app.get('/*foo*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>In class exercise 10th May, 2017</title></head><body>' + config.foo + '</body></html>') }); app.get('*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>In class exercise 10th May, 2017</title></head><body>' + config.goo + '</body></html>') }); app.listen(8888, function () { console.log('Server listening on port 8888!') });
[ Next ]
X