2
3
4
var app = connect()
.use(connect.logger('dev'))
.use(connect.static('public'))
.use(function (req, res) {
res.end('hello...
5
function SampleMiddleware(req, res, next) {
next();
}
6
7
8
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' })...
9
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' })...
10
e.g. http://examplewebsite/customers/showall
http://examplewebsite/customers/add
http://examplewebsite/customers/delete
11
12
https://github.com/visionmedia/consolidate.js
app.engine('jade', require('jade').__express);
app.set('view engine', 'ja...
13
res.render('email', { name: 'Tobi' }, function (err, html)
{
// ...
});
14
15
16
17
node.js workshop- node.js middleware
Upcoming SlideShare
Loading in...5
×

node.js workshop- node.js middleware

795

Published on

Published in: Software, Technology, Design

node.js workshop- node.js middleware

  1. 1. 2
  2. 2. 3
  3. 3. 4 var app = connect() .use(connect.logger('dev')) .use(connect.static('public')) .use(function (req, res) { res.end('hello worldn'); }) http.createServer(app).listen(3000);
  4. 4. 5 function SampleMiddleware(req, res, next) { next(); }
  5. 5. 6
  6. 6. 7
  7. 7. 8 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
  8. 8. 9 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); var express = require('express'); var app = express(); app.get('/', function (req, res) { res.send('hello world'); }); app.listen(3000);
  9. 9. 10 e.g. http://examplewebsite/customers/showall http://examplewebsite/customers/add http://examplewebsite/customers/delete
  10. 10. 11
  11. 11. 12 https://github.com/visionmedia/consolidate.js app.engine('jade', require('jade').__express); app.set('view engine', 'jade');
  12. 12. 13 res.render('email', { name: 'Tobi' }, function (err, html) { // ... });
  13. 13. 14
  14. 14. 15
  15. 15. 16
  16. 16. 17
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×