Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinchisholm/742b6e47add92d4e64b893414ca8f939 to your computer and use it in GitHub Desktop.
Save kevinchisholm/742b6e47add92d4e64b893414ca8f939 to your computer and use it in GitHub Desktop.
//require the express nodejs module
var express = require('express'),
//set an instance of exress
app = express();
//tell express what to do when the / route is requested
app.get('/', function (req, res) {
var i = 1,
max = 5;
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
for (; i <= max; i++) {
res.send('<h1>This is the response #: ' + i + '</h1>');
}
});
//wait for a connection
app.listen(5000, function () {
console.log('The web server is running. Please open http://localhost:5000/ in your browser.');
});
//require the express nodejs module
var express = require('express'),
//set an instance of exress
app = express();
//tell express what to do when the / route is requested
app.get('/', function (req, res) {
var i = 1,
max = 5;
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
for (; i <= max; i++) {
res.write('<h1>This is the response #: ' + i + '</h1>');
}
});
//wait for a connection
app.listen(5000, function () {
console.log('The web server is running. Please open http://localhost:5000/ in your browser.');
});
//require the express nodejs module
var express = require('express'),
//set an instance of exress
app = express();
//tell express what to do when the / route is requested
app.get('/', function (req, res) {
var i = 1,
max = 5;
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
for (; i <= max; i++) {
res.write('<h1>This is the response #: ' + i + '</h1>');
}
//end the response process
res.end();
});
//wait for a connection
app.listen(5000, function () {
console.log('The web server is running. Please open http://localhost:5000/ in your browser.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment