CS6320:  SW Engineering of Web Based Systems

 

Express Serving Static Files

use express.static middleware to serve static css, html and js (client side) files

 

below indicates the public subdirection in main appication directory contains the static files

app.use(express.static('public'))

Now, you can load the files that are in the public directory: (assumming listing at port 3000)

  http://localhost:3000/images/kitten.jpg
  http://localhost:3000/css/style.css
  http://localhost:3000/js/app.js
  http://localhost:3000/images/bg.png
  http://localhost:3000/hello.html

 

© Lynne Grewe