SlideShare una empresa de Scribd logo
1 de 17
Jitendra Zaa
What is Node.js
 Is Light Weight Server
 Used to create scalable network based application
using JavaScript like Syntax
Why Node.js
 Uses same JavaScript engine which is used by Google Chrome
Browser “V8 JavaScript Runtime”.
 Mostly for very Low level network programming
 Very fast because most of modules created in C language
 Single Threaded application
 It is not web development framework and not a complete
replacement of PHP or Ruby like language.
 However, there are few modules available like “Express.js” to
create Single page applications
What's Different about Node.js
 Most expensive job for processor is reading content
from Harddisc (IO Jobs).
 Most programming languages wait for read/write to
complete and then executes next statement.

 Unlike others, node.js executes IO operations
asynchronously and callback method is used to
resume an operation which needs to be completed
after IO.
How to Install
 Install Node.js SDK from http://nodejs.org/
First Program – Hello World
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello Worldn");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
Running First Program
 Save Code shown on previous slide in file named
“HelloWorld.js”
 Open Command Prompt and run file with Node
command
Running First Program (cont)
 On Console, you would see message saying Server is
running.
 And we open address “http://localhost:8000/” in
browser, Hello world will be displayed
Creating Web Application
ExpressJs - Install Node Modules
 Express (http://expressjs.com/) is mostly adapted web
module for Node.js to create Single page websites.
 To Install ExpressJs Module, create “Package.json” in
folder
 “Package.json” has metadata informations for module
needs to be installed
Package.json
{
"name": "hello-world",
"description": "hello world test app",
"version": "0.0.1",
"private": true,
"dependencies": { "express": "3.x" }
}
Installing ExpressJs Module
After creation of “Package.json”, run command
npm install
in folder where “package.json” exists.
Simplest Web Application in
Node.js
var express = require('express');
var app = express(); // create our app w/ express
app.configure(function() {
app.use(express.logger('dev')); // log every request to the console
app.use(express.json()); // Do not use bodyParser() , Instead use json() and urlencoded()
app.use(express.urlencoded()); // bodyparser() is depreciated from Express 3.0
});
app.get('/2', function(req, res) {
res.sendfile(__dirname + '/Page2.html');
});
app.get('*', function(req, res) {
res.sendfile(__dirname + '/Test Arrow.html');
});
app.listen(8080); //Listen on Port
console.log("App listening on port 8080");
Creating Sample HTML Files
 Save code of previous slide, in file named
“ExpressDemo.js”
 Html File 1 – “Test Arrow.html”
 Html File 2 – “Page2.html”
 Start Node application using command “node
ExpressDemo.js”
Running Web application
 Initially on navigation at http://localhost:8080/ we will
see content of “Test Arrow.html” file.
 If we change URL with something like
http://localhost:8080/2 , node server will post content
of file “Page2.html”
Output
Thanks !!!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
A slightly advanced introduction to node.js
A slightly advanced introduction to node.jsA slightly advanced introduction to node.js
A slightly advanced introduction to node.js
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Node js first look - 2016
Node js first look - 2016Node js first look - 2016
Node js first look - 2016
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Node js
Node jsNode js
Node js
 
Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?Why You Should Use MERN Stack for Startup Apps?
Why You Should Use MERN Stack for Startup Apps?
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Server Side Apocalypse, JS
Server Side Apocalypse, JSServer Side Apocalypse, JS
Server Side Apocalypse, JS
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Developing apps in Windows Containers using Docker
Developing apps in Windows Containers using DockerDeveloping apps in Windows Containers using Docker
Developing apps in Windows Containers using Docker
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Mern stack
Mern stackMern stack
Mern stack
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 

Destacado

San Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend FrameworkSan Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend Framework
zend
 

Destacado (20)

Zend framework: Getting to grips (ZF1)
Zend framework: Getting to grips (ZF1)Zend framework: Getting to grips (ZF1)
Zend framework: Getting to grips (ZF1)
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Intro to Laravel 4 : By Chris Moore
Intro to Laravel 4 : By Chris Moore Intro to Laravel 4 : By Chris Moore
Intro to Laravel 4 : By Chris Moore
 
Nature
NatureNature
Nature
 
Laravel 4 package development
Laravel 4 package developmentLaravel 4 package development
Laravel 4 package development
 
Node lt
Node ltNode lt
Node lt
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
Frontend technologies
Frontend technologiesFrontend technologies
Frontend technologies
 
Big Data loves JS
Big Data loves JSBig Data loves JS
Big Data loves JS
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
 
San Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend FrameworkSan Francisco PHP Meetup Presentation on Zend Framework
San Francisco PHP Meetup Presentation on Zend Framework
 
Laravel tips
Laravel tipsLaravel tips
Laravel tips
 
Cooking with jQuery
Cooking with jQueryCooking with jQuery
Cooking with jQuery
 
Zend Framework Getting Started For I5
Zend Framework Getting Started For I5Zend Framework Getting Started For I5
Zend Framework Getting Started For I5
 
PHPBootcamp - Zend Framework
PHPBootcamp - Zend FrameworkPHPBootcamp - Zend Framework
PHPBootcamp - Zend Framework
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
SITCON2014 LT 快倒的座位表
SITCON2014 LT 快倒的座位表SITCON2014 LT 快倒的座位表
SITCON2014 LT 快倒的座位表
 
Zend Framework Components for non-framework Development
Zend Framework Components for non-framework DevelopmentZend Framework Components for non-framework Development
Zend Framework Components for non-framework Development
 

Similar a Starting with Node.js

Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdf
Abanti Aazmin
 

Similar a Starting with Node.js (20)

Nodejs
NodejsNodejs
Nodejs
 
Introduction to node.js
Introduction to  node.jsIntroduction to  node.js
Introduction to node.js
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
Proposal
ProposalProposal
Proposal
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platform
 
Node js getting started
Node js getting startedNode js getting started
Node js getting started
 
node.js.pptx
node.js.pptxnode.js.pptx
node.js.pptx
 
Create Restful Web Application With Node.js Express Framework
Create Restful Web Application With Node.js Express FrameworkCreate Restful Web Application With Node.js Express Framework
Create Restful Web Application With Node.js Express Framework
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptx
 
Node js
Node jsNode js
Node js
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
5.node js
5.node js5.node js
5.node js
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdf
 

Más de Jitendra Zaa

Más de Jitendra Zaa (20)

Episode 13 - Advanced Apex Triggers
Episode 13 - Advanced Apex TriggersEpisode 13 - Advanced Apex Triggers
Episode 13 - Advanced Apex Triggers
 
Episode 18 - Asynchronous Apex
Episode 18 - Asynchronous ApexEpisode 18 - Asynchronous Apex
Episode 18 - Asynchronous Apex
 
Episode 15 - Basics of Javascript
Episode 15 - Basics of JavascriptEpisode 15 - Basics of Javascript
Episode 15 - Basics of Javascript
 
Episode 23 - Design Pattern 3
Episode 23 - Design Pattern 3Episode 23 - Design Pattern 3
Episode 23 - Design Pattern 3
 
Episode 24 - Live Q&A for getting started with Salesforce
Episode 24 - Live Q&A for getting started with SalesforceEpisode 24 - Live Q&A for getting started with Salesforce
Episode 24 - Live Q&A for getting started with Salesforce
 
Episode 22 - Design Pattern 2
Episode 22 - Design Pattern 2Episode 22 - Design Pattern 2
Episode 22 - Design Pattern 2
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
 
Episode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in SalesforceEpisode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in Salesforce
 
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulers
 
Episode 17 - Handling Events in Lightning Web Component
Episode 17 - Handling Events in Lightning Web ComponentEpisode 17 - Handling Events in Lightning Web Component
Episode 17 - Handling Events in Lightning Web Component
 
Episode 16 - Introduction to LWC
Episode 16 - Introduction to LWCEpisode 16 - Introduction to LWC
Episode 16 - Introduction to LWC
 
Introduction to mulesoft - Alpharetta Developer Group Meet
Introduction to mulesoft - Alpharetta Developer Group MeetIntroduction to mulesoft - Alpharetta Developer Group Meet
Introduction to mulesoft - Alpharetta Developer Group Meet
 
Episode 12 - Basics of Trigger
Episode 12 - Basics of TriggerEpisode 12 - Basics of Trigger
Episode 12 - Basics of Trigger
 
Episode 11 building & exposing rest api in salesforce v1.0
Episode 11   building & exposing rest api in salesforce v1.0Episode 11   building & exposing rest api in salesforce v1.0
Episode 11 building & exposing rest api in salesforce v1.0
 
Episode 10 - External Services in Salesforce
Episode 10 - External Services in SalesforceEpisode 10 - External Services in Salesforce
Episode 10 - External Services in Salesforce
 
Episode 14 - Basics of HTML for Salesforce
Episode 14 - Basics of HTML for SalesforceEpisode 14 - Basics of HTML for Salesforce
Episode 14 - Basics of HTML for Salesforce
 
South East Dreamin 2019
South East Dreamin 2019South East Dreamin 2019
South East Dreamin 2019
 
Episode 9 - Building soap integrations in salesforce
Episode 9 - Building soap integrations  in salesforceEpisode 9 - Building soap integrations  in salesforce
Episode 9 - Building soap integrations in salesforce
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
 
Episode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in SalesforceEpisode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in Salesforce
 

Último

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Último (20)

TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 

Starting with Node.js

  • 2. What is Node.js  Is Light Weight Server  Used to create scalable network based application using JavaScript like Syntax
  • 3. Why Node.js  Uses same JavaScript engine which is used by Google Chrome Browser “V8 JavaScript Runtime”.  Mostly for very Low level network programming  Very fast because most of modules created in C language  Single Threaded application  It is not web development framework and not a complete replacement of PHP or Ruby like language.  However, there are few modules available like “Express.js” to create Single page applications
  • 4. What's Different about Node.js  Most expensive job for processor is reading content from Harddisc (IO Jobs).  Most programming languages wait for read/write to complete and then executes next statement.   Unlike others, node.js executes IO operations asynchronously and callback method is used to resume an operation which needs to be completed after IO.
  • 5. How to Install  Install Node.js SDK from http://nodejs.org/
  • 6. First Program – Hello World // Load the http module to create an http server. var http = require('http'); // Configure our HTTP server to respond with Hello World to all requests. var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("Hello Worldn"); }); // Listen on port 8000, IP defaults to 127.0.0.1 server.listen(8000); // Put a friendly message on the terminal console.log("Server running at http://127.0.0.1:8000/");
  • 7. Running First Program  Save Code shown on previous slide in file named “HelloWorld.js”  Open Command Prompt and run file with Node command
  • 8. Running First Program (cont)  On Console, you would see message saying Server is running.  And we open address “http://localhost:8000/” in browser, Hello world will be displayed
  • 10. ExpressJs - Install Node Modules  Express (http://expressjs.com/) is mostly adapted web module for Node.js to create Single page websites.  To Install ExpressJs Module, create “Package.json” in folder  “Package.json” has metadata informations for module needs to be installed
  • 11. Package.json { "name": "hello-world", "description": "hello world test app", "version": "0.0.1", "private": true, "dependencies": { "express": "3.x" } }
  • 12. Installing ExpressJs Module After creation of “Package.json”, run command npm install in folder where “package.json” exists.
  • 13. Simplest Web Application in Node.js var express = require('express'); var app = express(); // create our app w/ express app.configure(function() { app.use(express.logger('dev')); // log every request to the console app.use(express.json()); // Do not use bodyParser() , Instead use json() and urlencoded() app.use(express.urlencoded()); // bodyparser() is depreciated from Express 3.0 }); app.get('/2', function(req, res) { res.sendfile(__dirname + '/Page2.html'); }); app.get('*', function(req, res) { res.sendfile(__dirname + '/Test Arrow.html'); }); app.listen(8080); //Listen on Port console.log("App listening on port 8080");
  • 14. Creating Sample HTML Files  Save code of previous slide, in file named “ExpressDemo.js”  Html File 1 – “Test Arrow.html”  Html File 2 – “Page2.html”  Start Node application using command “node ExpressDemo.js”
  • 15. Running Web application  Initially on navigation at http://localhost:8080/ we will see content of “Test Arrow.html” file.  If we change URL with something like http://localhost:8080/2 , node server will post content of file “Page2.html”