node.js workshop- node.js basics
Upcoming SlideShare
Loading in...5
×
 

node.js workshop- node.js basics

on

  • 1,515 views

 

Statistics

Views

Total Views
1,515
Views on SlideShare
1,133
Embed Views
382

Actions

Likes
12
Downloads
90
Comments
1

14 Embeds 382

http://localhost 326
http://test2.ru 9
http://mymusicwall.co.uk 7
http://wall7.lcl 7
http://www.socialconnexion.dk 7
http://www.germanjunkyard.com 6
https://wpdev.ux.dsone.3ds.com 5
http://wallbeta.9lessons.info 4
http://wall.bragshare.com 3
http://www.animalstrust.com 2
http://abcsmall.com 2
http://www.cheeps.ch 2
http://yedje.fr 1
http://192.168.1.254 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Lucidly explained. This knowledge should surely encourage more Node.JS based development.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

node.js workshop- node.js basics Presentation Transcript

  • 1. 2
  • 2. 3
  • 3. 4
  • 4. 5
  • 5. 6
  • 6. 7
  • 7. 8 node > console.log('Hello World'); Hello World
  • 8. 9 console.log('Hello World'); >node app.js Hello World
  • 9. 10 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/');
  • 10. 11 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/');
  • 11. 12
  • 12. 13 exports.helloworld = function () { console.log('Hello World'); } var test = require('./test.js'); test.helloworld();
  • 13. 14 module.exports = function () { this.name = "test object"; this.color = "red"; this.size = "large"; } var test = require('./test.js'); var testObject = new test(); console.log('name:' + testObject.name); console.log('color:' + testObject.color); console.log('size:' + testObject.size);
  • 14. 15
  • 15. 16
  • 16. 17 { "name": "TestNodejsApp", "version": "0.0.0", "description": "TestNodejsApp", "private": true, "main": "app.js", "author": { "name": "Qiong Wu", "email": "" }, "dependencies": { "express": "3.4.4", "jade": "*", "stylus": "*" } }
  • 17. 18
  • 18. 19
  • 19. 20 server.on('connection', function (stream) { console.log('someone connected!'); }); server.once('connection', function (stream) { console.log('Ah, we have our first user!'); });
  • 20. 21 function Test(colour) { this.colour = colour; events.EventEmitter.call(this); this.sendEvent = function() { this.emit('EventSent'); } } Test.prototype.__proto__ = events.EventEmitter.prototype; var testObject = new Test('white'); testObject.on('EventSent', function() { console.log('Event received'); }); testObject.sendEvent();
  • 21. 22
  • 22. 23 // write 'hello, ' and then end with 'world!' http.createServer(function (req, res) { res.write('hello, '); res.end('world!'); // writing more now is not allowed! });
  • 23. 24