SlideShare a Scribd company logo
1 of 15
node.js
        Hello World


Node.js – Web Framework
           By:Pravin Mishra
                pravinmisrha88@gmail.com
Contents
•   Why Node.js?
•   Node Overview
•   Benefits of Node.js
•   Create Server Request.
•   Write HTTP Header.
•   listen for new requests .
•   print out a message.
•   Run program.
•   Questions?
Why Node.js?


->Node's goal is to provide an easy
way to build scalable network
Programs.

->Keep slow operations from
blocking other operations.
What is Node.js?

->Standard library.
Timers, Process, Events, Util, Buffer,
Crypto, TLS/SSL, FileSystem, Net, DNS,
HTTP/HTTPS, URL, UDP.
-> I/O needs to be done differently
Templating

• Jade.

• EJS.

• Haml.

• Sass
Database

• Mysql

• Redis

• MongoDB

• CouchBD
Deploy

• Heroku




• Nodejitsu


• Cluster
Benefits of Node.js

- No need to wait for the disk,
do something else meanwhile!

   - Keep slow operations from
blocking other operations.

  - To read info from disk, network, ... there must be a
callback

-Asynchronous event-driven model
Create Server Rquest

var http = require("http");
http.createServer(function (request, response)
{
   response.end("<h2>This is the end!</h2>");
}).listen(3000, “127.0.0.1″);

->The require function will return an object representing the module that you
pass into it and you can capture that object in a variable.

->The createServer that takes a callback function and returns a new server
object.
Write HTTP headers.
var http = require("http");
http.createServer(function (request, response)
{
      res.writeHead(200, {‘content-Type’:'text/html’});
      response.end("<h2>This is the end!</h2>");
}).listen(3000, “127.0.0.1″);

->Then first need to write the appropriate HTTP headers.
->The writeHead function takes a couple of arguments. The
  first is an integer value representing the status code of the
  request which for us will be 200, in other words
write function
var http = require("http");
http.createServer(function (request, response)
{
      res.writeHead(200, {‘content-Type’:'text/html’});
       res.write(“<h1>Hello Word!</h1>”)
      response.end("<h2>This is the end!</h2>");
}).listen(3000, “127.0.0.1″);

->Then we’ll call the write function and pass in the data
  that you wish to send.
listen for new requests

var http = require("http");
http.createServer(function (request, response)
{
      res.writeHead(200, {‘content-Type’:'text/html’});
       res.write(“<h1>Hello Word!</h1>”)
      response.end("<h2>This is the end!</h2>");
}).listen(3000, “127.0.0.1″);

->The listen function on our server object and pass in a
  port number for it to listen on(3000). The listen function
  also takes an optional second parameter which is the
  hostname URL(“127.0.0.1″),
print out a message

var http = require("http");
http.createServer(function (request, response)
{
      res.writeHead(200, {‘content-Type’:'text/html’});
       res.write(“<h1>Hello Word!</h1>”)
      response.end("<h2>This is the end!</h2>");
}).listen(3000, “127.0.0.1″);
console.log(“Listening on http://127.0.0.1:3000“).

->Finally, let’s print out a message to let us know that our
  server is running
Run Program


There we go, now let’s run our app by calling node and passing
  to it the name of the file we want it to execute.




node hello_world.js and open browser “http://127.0.0.1:3000“



That’s it. Enjoy………………..
THANKS

     Questions?

     By:Pravin Mishra
    Rails/UI Developer
pravinmishra88@gmail.com

More Related Content

What's hot

高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
Ryousei Takano
 
Distributed in memory data grid
Distributed in memory data gridDistributed in memory data grid
Distributed in memory data grid
Alexander Albul
 
CHI - YAPC NA 2012
CHI - YAPC NA 2012CHI - YAPC NA 2012
CHI - YAPC NA 2012
jonswar
 
CHI-YAPC-2009
CHI-YAPC-2009CHI-YAPC-2009
CHI-YAPC-2009
jonswar
 
A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
Mingli Yuan
 

What's hot (20)

Caching. api. http 1.1
Caching. api. http 1.1Caching. api. http 1.1
Caching. api. http 1.1
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP Tricks
 
Building HTTP API's with NodeJS and MongoDB
Building HTTP API's with NodeJS and MongoDBBuilding HTTP API's with NodeJS and MongoDB
Building HTTP API's with NodeJS and MongoDB
 
Distributed in memory data grid
Distributed in memory data gridDistributed in memory data grid
Distributed in memory data grid
 
Introducing Vault
Introducing VaultIntroducing Vault
Introducing Vault
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with Elasticsearch
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
Vault - Secret and Key Management
Vault - Secret and Key ManagementVault - Secret and Key Management
Vault - Secret and Key Management
 
Exploring Node.jS
Exploring Node.jSExploring Node.jS
Exploring Node.jS
 
HashiCorp's Vault - The Examples
HashiCorp's Vault - The ExamplesHashiCorp's Vault - The Examples
HashiCorp's Vault - The Examples
 
CHI - YAPC NA 2012
CHI - YAPC NA 2012CHI - YAPC NA 2012
CHI - YAPC NA 2012
 
Designing High Availability for HashiCorp Vault in AWS
Designing High Availability for HashiCorp Vault in AWSDesigning High Availability for HashiCorp Vault in AWS
Designing High Availability for HashiCorp Vault in AWS
 
Virtual Hosting With Apache and Linux
Virtual Hosting With Apache and LinuxVirtual Hosting With Apache and Linux
Virtual Hosting With Apache and Linux
 
CHI-YAPC-2009
CHI-YAPC-2009CHI-YAPC-2009
CHI-YAPC-2009
 
A Brief Introduce to WSGI
A Brief Introduce to WSGIA Brief Introduce to WSGI
A Brief Introduce to WSGI
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
 
Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4
 
Architecting Secure and Compliant Applications with MongoDB
Architecting Secure and Compliant Applications with MongoDB        Architecting Secure and Compliant Applications with MongoDB
Architecting Secure and Compliant Applications with MongoDB
 

Similar to Node.js

Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
Cosmin Mereuta
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Richard Lee
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
Tom Croucher
 

Similar to Node.js (20)

Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
node js.pptx
node js.pptxnode js.pptx
node js.pptx
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node.js
Node.jsNode.js
Node.js
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Node JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint PresentationNode JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint Presentation
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
 
Node JS
Node JSNode JS
Node JS
 

More from Pravin Mishra

A journey from monolith to micro services
A journey from monolith to micro servicesA journey from monolith to micro services
A journey from monolith to micro services
Pravin Mishra
 

More from Pravin Mishra (8)

A journey from monolith to micro services
A journey from monolith to micro servicesA journey from monolith to micro services
A journey from monolith to micro services
 
App42 PaaS - Application Hosting Platform
App42 PaaS - Application Hosting PlatformApp42 PaaS - Application Hosting Platform
App42 PaaS - Application Hosting Platform
 
Happy Go programing
Happy Go programingHappy Go programing
Happy Go programing
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )
 
Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?
 
App42 PaaS
App42 PaaSApp42 PaaS
App42 PaaS
 
Hosting rails apps
Hosting rails appsHosting rails apps
Hosting rails apps
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin Mishra
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Node.js

  • 1. node.js Hello World Node.js – Web Framework By:Pravin Mishra pravinmisrha88@gmail.com
  • 2. Contents • Why Node.js? • Node Overview • Benefits of Node.js • Create Server Request. • Write HTTP Header. • listen for new requests . • print out a message. • Run program. • Questions?
  • 3. Why Node.js? ->Node's goal is to provide an easy way to build scalable network Programs. ->Keep slow operations from blocking other operations.
  • 4. What is Node.js? ->Standard library. Timers, Process, Events, Util, Buffer, Crypto, TLS/SSL, FileSystem, Net, DNS, HTTP/HTTPS, URL, UDP. -> I/O needs to be done differently
  • 6. Database • Mysql • Redis • MongoDB • CouchBD
  • 8. Benefits of Node.js - No need to wait for the disk, do something else meanwhile! - Keep slow operations from blocking other operations. - To read info from disk, network, ... there must be a callback -Asynchronous event-driven model
  • 9. Create Server Rquest var http = require("http"); http.createServer(function (request, response) { response.end("<h2>This is the end!</h2>"); }).listen(3000, “127.0.0.1″); ->The require function will return an object representing the module that you pass into it and you can capture that object in a variable. ->The createServer that takes a callback function and returns a new server object.
  • 10. Write HTTP headers. var http = require("http"); http.createServer(function (request, response) { res.writeHead(200, {‘content-Type’:'text/html’}); response.end("<h2>This is the end!</h2>"); }).listen(3000, “127.0.0.1″); ->Then first need to write the appropriate HTTP headers. ->The writeHead function takes a couple of arguments. The first is an integer value representing the status code of the request which for us will be 200, in other words
  • 11. write function var http = require("http"); http.createServer(function (request, response) { res.writeHead(200, {‘content-Type’:'text/html’}); res.write(“<h1>Hello Word!</h1>”) response.end("<h2>This is the end!</h2>"); }).listen(3000, “127.0.0.1″); ->Then we’ll call the write function and pass in the data that you wish to send.
  • 12. listen for new requests var http = require("http"); http.createServer(function (request, response) { res.writeHead(200, {‘content-Type’:'text/html’}); res.write(“<h1>Hello Word!</h1>”) response.end("<h2>This is the end!</h2>"); }).listen(3000, “127.0.0.1″); ->The listen function on our server object and pass in a port number for it to listen on(3000). The listen function also takes an optional second parameter which is the hostname URL(“127.0.0.1″),
  • 13. print out a message var http = require("http"); http.createServer(function (request, response) { res.writeHead(200, {‘content-Type’:'text/html’}); res.write(“<h1>Hello Word!</h1>”) response.end("<h2>This is the end!</h2>"); }).listen(3000, “127.0.0.1″); console.log(“Listening on http://127.0.0.1:3000“). ->Finally, let’s print out a message to let us know that our server is running
  • 14. Run Program There we go, now let’s run our app by calling node and passing to it the name of the file we want it to execute. node hello_world.js and open browser “http://127.0.0.1:3000“ That’s it. Enjoy………………..
  • 15. THANKS Questions? By:Pravin Mishra Rails/UI Developer pravinmishra88@gmail.com