Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gfnork node.js workshop Lesson #4 middleware fo...

Avatar for gfnork gfnork
June 20, 2014

gfnork node.js workshop Lesson #4 middleware for node

connect.js, express.js and other fun things

Avatar for gfnork

gfnork

June 20, 2014
Tweet

More Decks by gfnork

Other Decks in Programming

Transcript

  1. 2

  2. 3

  3. 4 var app = connect() .use(connect.logger('dev')) .use(connect.static('public')) .use(function (req, res)

    { res.end('hello world\n'); }) http.createServer(app).listen(3000);
  4. 6

  5. 7

  6. 8 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200,

    { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
  7. 9 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200,

    { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).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);
  8. 11

  9. 14

  10. 15

  11. 16

  12. 17