[ Prev ]
2017-05-10

-- May 10 In-Class Exercise
Name: Mohammad Rizvi
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!"); });
(Edited: 2017-05-11)
Name: Mohammad Rizvi 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
 Mykhailo Behei
 //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 logger = function(req, res, next) {
     console.log(req.ip + " --> " + req.path);
     next();
 }
 app.use(logger);
 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>')
 })
 app.listen(8888, function() {
    console.log('Server running on 8888!')
 })
Mykhailo Behei //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 logger = function(req, res, next) { console.log(req.ip + " --> " + req.path); next(); } app.use(logger); 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>') }) app.listen(8888, function() { console.log('Server running on 8888!') })

-- May 10 In-Class Exercise
Yash Parikh.
var expressApp = express();
var configuration = require('./config') var express = require('express');
var log = function (req, res, next) {
	console.log(req.ip + " which is --->> " + req.path)
	next()
}; expressApp.use(log);
expressApp.get('/*foo*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + configuration.foo + '</body></html>')
});
expressApp.get('*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + configuration.goo + '</body></html>')
});
app.listen(8888, function () {
	console.log('Server listening on port 8888! Go to http://localhost:3000')
});
Yash Parikh. var expressApp = express(); var configuration = require('./config') var express = require('express'); var log = function (req, res, next) { console.log(req.ip + " which is --->> " + req.path) next() }; expressApp.use(log); expressApp.get('/*foo*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + configuration.foo + '</body></html>') }); expressApp.get('*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + configuration.goo + '</body></html>') }); app.listen(8888, function () { console.log('Server listening on port 8888! Go to http://localhost:3000') });
2017-05-15

-- May 10 In-Class Exercise
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>app</title><meta charset="utf-8" /></head><body>' + config.foo + '</body></html>')
});
app.get('*', function (req, res) {
	res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + config.goo + '</body></html>')
});
app.listen(8888, function () {
	console.log('Server listening on port 8888! Go to http://localhost:3000')
});
 
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>app</title><meta charset="utf-8" /></head><body>' + config.foo + '</body></html>') }); app.get('*', function (req, res) { res.send('<!DOCTYPE html><html><head><title>app</title><meta charset="utf-8" /></head><body>' + config.goo + '</body></html>') }); app.listen(8888, function () { console.log('Server listening on port 8888! Go to http://localhost:3000') });
X