Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Building a Website with
Sarunyhot Suvannachoti (Kao)
Software Engineer @ Jitta.com
Express.js
What is express?
• Node.js web application framework
• Inspired by Sinatra
• Asynchronous
Routing
Routing
Route handlers
Response methods
Method Description
res.download() Prompt a file to be downloaded.
res.end() End the response process.
res....
Chainable route
Middleware
Browser
Request
app.get(‘/user’)
app.post(‘/blog’)
app.delete(‘/book’)
Middleware
Browser
Request
app.get(‘/user’)
middleware app.post(‘/blog’)
app.delete(‘/book’)
Middleware
Browser
Request
app.get(‘/user’)
checkAdmin
app.post(‘/blog’)
app.delete(‘/book’)
logRequest
checkLogin
checkAc...
Middleware
Upcoming SlideShare
Loading in …5
×

Build web application with express

563 views

Published on

Introduction to expressjs.

Published in: Technology
  • Be the first to comment

Build web application with express

  1. 1. Building a Website with Sarunyhot Suvannachoti (Kao) Software Engineer @ Jitta.com Express.js
  2. 2. What is express? • Node.js web application framework • Inspired by Sinatra • Asynchronous
  3. 3. Routing
  4. 4. Routing
  5. 5. Route handlers
  6. 6. Response methods Method Description res.download() Prompt a file to be downloaded. res.end() End the response process. res.json() Send a JSON response. res.jsonp() Send a JSON response with JSONP support. res.redirect() Redirect a request. res.render() Render a view template. res.send() Send a response of various types. res.sendFile Send a file as an octet stream. res.sendStatus() Set the response status code and send its string representation as the response body.
  7. 7. Chainable route
  8. 8. Middleware Browser Request app.get(‘/user’) app.post(‘/blog’) app.delete(‘/book’)
  9. 9. Middleware Browser Request app.get(‘/user’) middleware app.post(‘/blog’) app.delete(‘/book’)
  10. 10. Middleware Browser Request app.get(‘/user’) checkAdmin app.post(‘/blog’) app.delete(‘/book’) logRequest checkLogin checkAccess
  11. 11. Middleware

×