SlideShare a Scribd company logo
2
Most read
3
Most read
8
Most read
ExpressJS
Web development with ExpressJS
Learning & Development
Table of Contents
1. Connect for NodeJS
2. ExpressJS
3. Views and layout
4. Working with Data
5. Common and Advanced Scenarios
2
node.js
• Event-Driven, Asynchronous IO, Server-Side JavaScript library in C
• Open Source
• Available on
• Windows
• Service
• Under IIS (iisnode)
• *nix systems
• As a service
• Azure
• Heroku
3
NodeJS Web Server
• Basic server implementation
4
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain'
}); //return success header
res.write('My server is running! ^_^'); //response
res.end(); //finish processing current request
}).listen(1234);
Connect for NodeJS
• Connect is a middleware framework for node
• Built on top of node’s Http Server
• http://www.senchalabs.org/connect/
5
var connect = require('connect');
var app = connect()
.use(connect.logger('dev'))
.use(connect.static('public'))
.use(function(req, res){
res.end('hello worldn');
})
http.createServer(app).listen(3000);
$ npm install connect
Connect Middleware
• Request Processing Pipeline
6
ResponseRequest
Middleware (logging, authentication, etc.)
Connect for NodeJS – Example
• Custom middleware function for connect
7
var connect = require('connect'),
util = require('util');
var interceptorFunction = function(request, response, next) {
console.log(util.format('Request for %s with method %s',
request.url, request.method));
next();
};
var app = connect()
// .use('/log', interceptorFunction)
.use(interceptorFunction)
.use(function onRequest(request, response) {
response.end('Hello from Connect!');
}).listen(3001);
Express.js
• Adds functionality to Connect
• Built on top of Connect Middleware
• Request / Response enhancements
• Routing
• View Support
• HTML Helpers
• Content Negotiation
• Exposes Connect Middleware
8
Basic Architecture
9
Request
View
File
XML
JSON
etc. Function
Routing
First Express App
10
var express = require('express');
var app = express();
app.get('/', function (request, response) {
response.send('Welcome to Express!');
});
app.get('/customer/:id', function (req, res) {
res.send('Customer requested is ' + req.params['id']);
});
app.listen(3000);
Demo: Creating Express
Applications
• Simple ExpressJS application and "nodemon"
• Create routes and require() them
• Pass parameters
• Configure and middleware
Views in ExpressJS
• User Interface
• Based on Templates
• Support for multiple View Engines
• Jade, EJS, JSHtml, . . .
• Default is Jade
• http://jade-lang.com
12
app.get('/', function (req, res) {
res.render('index');
});
Views in ExpressJS – Example
13
var express = require('express'),
path = require('path');
var app = express();
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/', function (req, res) {
res.render('empty');
});
app.listen(3000);
doctype
html(lang="en")
head
title Welcome to this emtpy page
body
Demo: Views in ExpressJS
• Show simple views in ExpressJS
• Jade syntax examples
• Layouts and blocks
• Stylus
Working with Data
• Pass data to the views
• Read data from the views (bodyParser)
• Read and send files
• Data for all views
15
res.render('index', { title: 'Customer List' });
res.render('index', { title: 'Customer List' });
var filePath = req.files.picture.path;
// ...
res.download(filePath);
res.sendfile(filePath);
app.locals.clock = { datetime: new Date().toUTCString()};
Demo: Working with data
• Pass data to views (customer.index)
• Submit data from views (customer.create)
• Content negotiation (customer.details)
• Upload files (customer.create)
• Helpers (app.locals)
Demo: Advanced Scenarios
• Cookies
• Sessions
• Custom middleware
• Authentication and authorization
17
Next Steps
• Express.js Samples
• https://github.com/visionmedia/express
• Database Support
• MS SQL
• CouchDB
• PostgreSQL
• Redis
• Socket.io
• Real-time support
18
Next Steps (2)
• Search on npm.org before you re-invent the wheel
• Express is Lightweight Framework and Fast to work with
• Testing is not optional
• Mocha
• JavaScript can get messy
19

More Related Content

PPTX
Node.js Express
Eyal Vardi
 
PPTX
Node js Introduction
sanskriti agarwal
 
PPTX
What Is Express JS?
Simplilearn
 
PPTX
Build RESTful API Using Express JS
Cakra Danu Sedayu
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PDF
Expressjs
Yauheni Nikanovich
 
PPT
Node.js Express Framework
TheCreativedev Blog
 
Node.js Express
Eyal Vardi
 
Node js Introduction
sanskriti agarwal
 
What Is Express JS?
Simplilearn
 
Build RESTful API Using Express JS
Cakra Danu Sedayu
 
Introduction Node.js
Erik van Appeldoorn
 
NodeJS for Beginner
Apaichon Punopas
 
Node.js Express Framework
TheCreativedev Blog
 

What's hot (20)

PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
PPTX
Introduction to Node.js
Vikash Singh
 
PDF
Express node js
Yashprit Singh
 
PPTX
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
PPTX
Express JS
Designveloper
 
PPTX
Introduction to NodeJS
Cere Labs Pvt. Ltd
 
PPTX
Express JS
Alok Guha
 
PPTX
Introduction to Node js
Akshay Mathur
 
PDF
Nodejs presentation
Arvind Devaraj
 
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PDF
introduction to Vue.js 3
ArezooKmn
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PPTX
Angularjs PPT
Amit Baghel
 
PPTX
jQuery
Dileep Mishra
 
PPTX
Node js introduction
Joseph de Castelnau
 
PDF
JavaScript Fetch API
Xcat Liu
 
PDF
Introduction to Node.JS Express
Eueung Mulyana
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
Introduction to Node.js
Vikash Singh
 
Express node js
Yashprit Singh
 
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
Express JS
Designveloper
 
Introduction to NodeJS
Cere Labs Pvt. Ltd
 
Express JS
Alok Guha
 
Introduction to Node js
Akshay Mathur
 
Nodejs presentation
Arvind Devaraj
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Visual Engineering
 
NodeJS - Server Side JS
Ganesh Kondal
 
[Final] ReactJS presentation
洪 鹏发
 
introduction to Vue.js 3
ArezooKmn
 
Introduction to spring boot
Santosh Kumar Kar
 
Angularjs PPT
Amit Baghel
 
Node js introduction
Joseph de Castelnau
 
JavaScript Fetch API
Xcat Liu
 
Introduction to Node.JS Express
Eueung Mulyana
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Ad

Viewers also liked (20)

PPTX
Building Web Apps with Express
Aaron Stannard
 
PPT
Building your first Node app with Connect & Express
Christian Joudrey
 
PDF
Create Restful Web Application With Node.js Express Framework
Edureka!
 
PDF
Nodejs Explained with Examples
Gabriele Lana
 
PDF
Expressjs basic to advance, power by Node.js
Caesar Chi
 
PPTX
Node JS Express : Steps to Create Restful Web App
Edureka!
 
PPTX
Diving into Node with Express and Mongo
Axilis
 
PDF
Node, express & sails
Brian Shannon
 
PPTX
Chinese new year- Aoife & Sarah
Ms Bergin
 
PPTX
Jade & Javascript templating
wearefractal
 
PPTX
Express js clean-controller
Asia Tyshchenko
 
PPT
The Business Case for Node.js
Joe McCann
 
PPTX
Rest api with node js and express
GirlsInTechnology Nepal
 
PPT
Postroenie sechenij mnogogrannikov
Dimon4
 
PPTX
Kraken js at paypal
Lenny Markus
 
PDF
Вячеслав Бирюков - Как Linux работает с памятью
Yandex
 
PPTX
Express yourself
Yaniv Rodenski
 
PPTX
React js
Oswald Campesato
 
PPTX
Сечения призмы и пирамиды
Dmitry Bulgakov
 
PDF
Node-IL Meetup 12/2
Ynon Perek
 
Building Web Apps with Express
Aaron Stannard
 
Building your first Node app with Connect & Express
Christian Joudrey
 
Create Restful Web Application With Node.js Express Framework
Edureka!
 
Nodejs Explained with Examples
Gabriele Lana
 
Expressjs basic to advance, power by Node.js
Caesar Chi
 
Node JS Express : Steps to Create Restful Web App
Edureka!
 
Diving into Node with Express and Mongo
Axilis
 
Node, express & sails
Brian Shannon
 
Chinese new year- Aoife & Sarah
Ms Bergin
 
Jade & Javascript templating
wearefractal
 
Express js clean-controller
Asia Tyshchenko
 
The Business Case for Node.js
Joe McCann
 
Rest api with node js and express
GirlsInTechnology Nepal
 
Postroenie sechenij mnogogrannikov
Dimon4
 
Kraken js at paypal
Lenny Markus
 
Вячеслав Бирюков - Как Linux работает с памятью
Yandex
 
Express yourself
Yaniv Rodenski
 
Сечения призмы и пирамиды
Dmitry Bulgakov
 
Node-IL Meetup 12/2
Ynon Perek
 
Ad

Similar to Express js (20)

PDF
Express: A Jump-Start
Naveen Pete
 
PPT
nodejs_at_a_glance, understanding java script
mohammedarshadhussai4
 
PPT
nodejs_at_a_glance.ppt
WalaSidhom1
 
PPTX
Unit 1 Express J for mean stack and mern
Rahul Borate
 
PPTX
express.js.pptxgghhhhhhnnbvcdssazxvuyiknvc
rani marri
 
PPTX
Starting with Node.js
Jitendra Zaa
 
PPTX
ExpressJs Session01
Jainul Musani
 
PPTX
Introduction to node.js
Md. Sohel Rana
 
PPTX
CH-2.2.1 (1).pptx hisnsmmzmznznNNNMamMamam
renunitin9919
 
PDF
What is Node.js? (ICON UK)
Tim Davis
 
PDF
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
PPT
Exploring Node.jS
Deepu S Nath
 
PPTX
Introduction to node.js
Adrien Guéret
 
PDF
express node and cmd sytax #express #node #cmd
AhmarWaseem1
 
PDF
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
PPTX
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
annalakshmi35
 
PPTX
23003468463PPT.pptx
annalakshmi35
 
PDF
Complete MVC on NodeJS
Hüseyin BABAL
 
PPTX
Introduction to Node.js
Winston Hsieh
 
PDF
MongoDB, Node.js And You: PART II
Mitch Pirtle
 
Express: A Jump-Start
Naveen Pete
 
nodejs_at_a_glance, understanding java script
mohammedarshadhussai4
 
nodejs_at_a_glance.ppt
WalaSidhom1
 
Unit 1 Express J for mean stack and mern
Rahul Borate
 
express.js.pptxgghhhhhhnnbvcdssazxvuyiknvc
rani marri
 
Starting with Node.js
Jitendra Zaa
 
ExpressJs Session01
Jainul Musani
 
Introduction to node.js
Md. Sohel Rana
 
CH-2.2.1 (1).pptx hisnsmmzmznznNNNMamMamam
renunitin9919
 
What is Node.js? (ICON UK)
Tim Davis
 
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
Exploring Node.jS
Deepu S Nath
 
Introduction to node.js
Adrien Guéret
 
express node and cmd sytax #express #node #cmd
AhmarWaseem1
 
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
annalakshmi35
 
23003468463PPT.pptx
annalakshmi35
 
Complete MVC on NodeJS
Hüseyin BABAL
 
Introduction to Node.js
Winston Hsieh
 
MongoDB, Node.js And You: PART II
Mitch Pirtle
 

More from Manav Prasad (20)

PPTX
Experience with mulesoft
Manav Prasad
 
PPTX
Mulesoftconnectors
Manav Prasad
 
PPT
Mule and web services
Manav Prasad
 
PPTX
Mulesoft cloudhub
Manav Prasad
 
PPT
Perl tutorial
Manav Prasad
 
PPT
Hibernate presentation
Manav Prasad
 
PPT
Jpa
Manav Prasad
 
PPT
Spring introduction
Manav Prasad
 
PPT
Json
Manav Prasad
 
PPT
The spring framework
Manav Prasad
 
PPT
Rest introduction
Manav Prasad
 
PPT
Exceptions in java
Manav Prasad
 
PPT
Junit
Manav Prasad
 
PPT
Xml parsers
Manav Prasad
 
PPT
Xpath
Manav Prasad
 
PPT
Xslt
Manav Prasad
 
PPT
Xhtml
Manav Prasad
 
PPT
Css
Manav Prasad
 
PPT
Introduction to html5
Manav Prasad
 
PPT
Ajax
Manav Prasad
 
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Manav Prasad
 
Hibernate presentation
Manav Prasad
 
Spring introduction
Manav Prasad
 
The spring framework
Manav Prasad
 
Rest introduction
Manav Prasad
 
Exceptions in java
Manav Prasad
 
Xml parsers
Manav Prasad
 
Introduction to html5
Manav Prasad
 

Recently uploaded (20)

PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
CDH. pptx
AneetaSharma15
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 

Express js

  • 1. ExpressJS Web development with ExpressJS Learning & Development
  • 2. Table of Contents 1. Connect for NodeJS 2. ExpressJS 3. Views and layout 4. Working with Data 5. Common and Advanced Scenarios 2
  • 3. node.js • Event-Driven, Asynchronous IO, Server-Side JavaScript library in C • Open Source • Available on • Windows • Service • Under IIS (iisnode) • *nix systems • As a service • Azure • Heroku 3
  • 4. NodeJS Web Server • Basic server implementation 4 var http = require('http'); http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); //return success header res.write('My server is running! ^_^'); //response res.end(); //finish processing current request }).listen(1234);
  • 5. Connect for NodeJS • Connect is a middleware framework for node • Built on top of node’s Http Server • http://www.senchalabs.org/connect/ 5 var connect = require('connect'); var app = connect() .use(connect.logger('dev')) .use(connect.static('public')) .use(function(req, res){ res.end('hello worldn'); }) http.createServer(app).listen(3000); $ npm install connect
  • 6. Connect Middleware • Request Processing Pipeline 6 ResponseRequest Middleware (logging, authentication, etc.)
  • 7. Connect for NodeJS – Example • Custom middleware function for connect 7 var connect = require('connect'), util = require('util'); var interceptorFunction = function(request, response, next) { console.log(util.format('Request for %s with method %s', request.url, request.method)); next(); }; var app = connect() // .use('/log', interceptorFunction) .use(interceptorFunction) .use(function onRequest(request, response) { response.end('Hello from Connect!'); }).listen(3001);
  • 8. Express.js • Adds functionality to Connect • Built on top of Connect Middleware • Request / Response enhancements • Routing • View Support • HTML Helpers • Content Negotiation • Exposes Connect Middleware 8
  • 10. First Express App 10 var express = require('express'); var app = express(); app.get('/', function (request, response) { response.send('Welcome to Express!'); }); app.get('/customer/:id', function (req, res) { res.send('Customer requested is ' + req.params['id']); }); app.listen(3000);
  • 11. Demo: Creating Express Applications • Simple ExpressJS application and "nodemon" • Create routes and require() them • Pass parameters • Configure and middleware
  • 12. Views in ExpressJS • User Interface • Based on Templates • Support for multiple View Engines • Jade, EJS, JSHtml, . . . • Default is Jade • http://jade-lang.com 12 app.get('/', function (req, res) { res.render('index'); });
  • 13. Views in ExpressJS – Example 13 var express = require('express'), path = require('path'); var app = express(); app.configure(function () { app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.static(path.join(__dirname, 'public'))); }); app.get('/', function (req, res) { res.render('empty'); }); app.listen(3000); doctype html(lang="en") head title Welcome to this emtpy page body
  • 14. Demo: Views in ExpressJS • Show simple views in ExpressJS • Jade syntax examples • Layouts and blocks • Stylus
  • 15. Working with Data • Pass data to the views • Read data from the views (bodyParser) • Read and send files • Data for all views 15 res.render('index', { title: 'Customer List' }); res.render('index', { title: 'Customer List' }); var filePath = req.files.picture.path; // ... res.download(filePath); res.sendfile(filePath); app.locals.clock = { datetime: new Date().toUTCString()};
  • 16. Demo: Working with data • Pass data to views (customer.index) • Submit data from views (customer.create) • Content negotiation (customer.details) • Upload files (customer.create) • Helpers (app.locals)
  • 17. Demo: Advanced Scenarios • Cookies • Sessions • Custom middleware • Authentication and authorization 17
  • 18. Next Steps • Express.js Samples • https://github.com/visionmedia/express • Database Support • MS SQL • CouchDB • PostgreSQL • Redis • Socket.io • Real-time support 18
  • 19. Next Steps (2) • Search on npm.org before you re-invent the wheel • Express is Lightweight Framework and Fast to work with • Testing is not optional • Mocha • JavaScript can get messy 19

Editor's Notes

  • #3: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*