SlideShare a Scribd company logo
1 of 9
Workshop
@
Ramnshee Infotech
By Jainul Musani
1
SESSION:01
Express JS
ExpressJs
 Express.js is a web framework that could be used
with Node.js.
 Express.js can start an application server
listening on a port in your machine.
 Express.js starts the application in a single
thread and handles HTTP methods like GET, POST,
DELETE, etc., asynchronously.
SESSION:01
Express JS
ExpressJs – Sample Server
 app.js
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send(‘Started Server with ExpressJs FrameWork')
res.end()
})
app.listen(8000)
SESSION:01
Express JS
Install Express.js
 Assuming you’ve already installed Node.js,
 create a directory to hold your application, and make
that your working directory.
C:nodejs> mkdir myapp
C:nodejs> cd myapp
 Use the npm init command to create a package.json file
for your application.
C:nodejs> npm init –y
 Now install Express in the myapp directory and save it
in the dependencies list.
C:nodejs> npm install express –save
SESSION:01
Express JS
Hello world example - Express.Js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at
http://localhost:${port}`)
})
SESSION:01
Express JS
Run “Hello World”
 Run the app with the following command:
C:nodejs> node app.js
SESSION:01
Express JS
Express.js Routes
 An Express.js Route defines how our Express application
can respond to a client request to with a specific URI (or
path) and a specific HTTP request method (GET, POST,
etc.).
 A basic Express application as shown below.
app.js
var express = require('express')
var app = express()
// start the server
var server = app.listen(8000, function(){
console.log('Listening on port 8000...')
})
SESSION:01
Express JS
Express.js Routes
 Here Express.js Routes come into picture.
app.get('/', function (req, res) {
res.send('This is a basic Example for Express.js')
})
SESSION:01
Express JS
Training Batch - Winter
Express.js Routes app.js
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Home.')
})
app.get('/hello/', function (req, res) {
res.send('Hello page.')
})
app.get('/bye/', function (req, res) {
res.send('Bye page.')
})
var server = app.listen(8000, function(){
console.log('Listening on port 8000...‘) // start the server
})
SESSION:01
Express JS

More Related Content

What's hot

Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
jorgecarabias
 

What's hot (17)

บทที่3
บทที่3บทที่3
บทที่3
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
IMPACT/myGrid Hackathon - Taverna Server as a Portal
IMPACT/myGrid Hackathon - Taverna Server as a PortalIMPACT/myGrid Hackathon - Taverna Server as a Portal
IMPACT/myGrid Hackathon - Taverna Server as a Portal
 
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
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in mule
 
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
 
G rpc lection1
G rpc lection1G rpc lection1
G rpc lection1
 
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
 
Node js first look - 2016
Node js first look - 2016Node js first look - 2016
Node js first look - 2016
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
 
Virtualbox and Mysql
Virtualbox and MysqlVirtualbox and Mysql
Virtualbox and Mysql
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
 
Oracle virtual server-2-t0-3-upgrade
Oracle virtual server-2-t0-3-upgradeOracle virtual server-2-t0-3-upgrade
Oracle virtual server-2-t0-3-upgrade
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Setup Kubernetes with flannel on ubuntu platform
Setup Kubernetes with flannel on ubuntu platformSetup Kubernetes with flannel on ubuntu platform
Setup Kubernetes with flannel on ubuntu platform
 
Node js
Node jsNode js
Node js
 

Similar to ExpressJs Session01

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
Shawn Meng
 

Similar to ExpressJs Session01 (20)

RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Node.jsやってみた
Node.jsやってみたNode.jsやってみた
Node.jsやってみた
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
Starting with Node.js
Starting with Node.jsStarting with Node.js
Starting with Node.js
 
Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Node intro
Node introNode intro
Node intro
 
Express.pdf
Express.pdfExpress.pdf
Express.pdf
 
ExpressJS-Introduction.pdf
ExpressJS-Introduction.pdfExpressJS-Introduction.pdf
ExpressJS-Introduction.pdf
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Express js
Express jsExpress js
Express js
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Build Web Apps using Node.js
Build Web Apps using Node.jsBuild Web Apps using Node.js
Build Web Apps using Node.js
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first class
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
 
NodeJS and ExpressJS.pdf
NodeJS and ExpressJS.pdfNodeJS and ExpressJS.pdf
NodeJS and ExpressJS.pdf
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
 

More from Jainul Musani

More from Jainul Musani (20)

Python: The Versatile Programming Language - Introduction
Python: The Versatile Programming Language - IntroductionPython: The Versatile Programming Language - Introduction
Python: The Versatile Programming Language - Introduction
 
Python a Versatile Programming Language - Introduction
Python a Versatile Programming Language - IntroductionPython a Versatile Programming Language - Introduction
Python a Versatile Programming Language - Introduction
 
React js t8 - inlinecss
React js   t8 - inlinecssReact js   t8 - inlinecss
React js t8 - inlinecss
 
React js t7 - forms-events
React js   t7 - forms-eventsReact js   t7 - forms-events
React js t7 - forms-events
 
React js t6 -lifecycle
React js   t6 -lifecycleReact js   t6 -lifecycle
React js t6 -lifecycle
 
React js t5 - state
React js   t5 - stateReact js   t5 - state
React js t5 - state
 
React js t4 - components
React js   t4 - componentsReact js   t4 - components
React js t4 - components
 
React js t3 - es6
React js   t3 - es6React js   t3 - es6
React js t3 - es6
 
React js t2 - jsx
React js   t2 - jsxReact js   t2 - jsx
React js t2 - jsx
 
React js t1 - introduction
React js   t1 - introductionReact js   t1 - introduction
React js t1 - introduction
 
NodeJs Session02
NodeJs Session02NodeJs Session02
NodeJs Session02
 
Java exercise1
Java exercise1Java exercise1
Java exercise1
 
Fundamentals of JDBC
Fundamentals of JDBCFundamentals of JDBC
Fundamentals of JDBC
 
Core Java Special
Core Java SpecialCore Java Special
Core Java Special
 
Core Java Special
Core Java SpecialCore Java Special
Core Java Special
 
Cassandra-vs-MongoDB
Cassandra-vs-MongoDBCassandra-vs-MongoDB
Cassandra-vs-MongoDB
 
MongoDB-SESSION03
MongoDB-SESSION03MongoDB-SESSION03
MongoDB-SESSION03
 
MongoDB-SESSION02
MongoDB-SESSION02MongoDB-SESSION02
MongoDB-SESSION02
 
MongoDB-SESION01
MongoDB-SESION01MongoDB-SESION01
MongoDB-SESION01
 
4+1archi
4+1archi4+1archi
4+1archi
 

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
 

Recently uploaded (20)

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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
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
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 

ExpressJs Session01

  • 1. Workshop @ Ramnshee Infotech By Jainul Musani 1 SESSION:01 Express JS
  • 2. ExpressJs  Express.js is a web framework that could be used with Node.js.  Express.js can start an application server listening on a port in your machine.  Express.js starts the application in a single thread and handles HTTP methods like GET, POST, DELETE, etc., asynchronously. SESSION:01 Express JS
  • 3. ExpressJs – Sample Server  app.js var express = require('express') var app = express() app.get('/', function (req, res) { res.send(‘Started Server with ExpressJs FrameWork') res.end() }) app.listen(8000) SESSION:01 Express JS
  • 4. Install Express.js  Assuming you’ve already installed Node.js,  create a directory to hold your application, and make that your working directory. C:nodejs> mkdir myapp C:nodejs> cd myapp  Use the npm init command to create a package.json file for your application. C:nodejs> npm init –y  Now install Express in the myapp directory and save it in the dependencies list. C:nodejs> npm install express –save SESSION:01 Express JS
  • 5. Hello world example - Express.Js const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World!') }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) SESSION:01 Express JS
  • 6. Run “Hello World”  Run the app with the following command: C:nodejs> node app.js SESSION:01 Express JS
  • 7. Express.js Routes  An Express.js Route defines how our Express application can respond to a client request to with a specific URI (or path) and a specific HTTP request method (GET, POST, etc.).  A basic Express application as shown below. app.js var express = require('express') var app = express() // start the server var server = app.listen(8000, function(){ console.log('Listening on port 8000...') }) SESSION:01 Express JS
  • 8. Express.js Routes  Here Express.js Routes come into picture. app.get('/', function (req, res) { res.send('This is a basic Example for Express.js') }) SESSION:01 Express JS Training Batch - Winter
  • 9. Express.js Routes app.js var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Home.') }) app.get('/hello/', function (req, res) { res.send('Hello page.') }) app.get('/bye/', function (req, res) { res.send('Bye page.') }) var server = app.listen(8000, function(){ console.log('Listening on port 8000...‘) // start the server }) SESSION:01 Express JS