(UPDATE: See node-static-http-servers repo for more examples of serving static files with express.static
, express
, connect
, http
and net
and better explanation)
Example for Stack Overflow answer:
Also referenced in other Stack Overflow answers:
- onload js call not working with node
- Sending whole folder content to client with express
- Loading partials fails on the server JS
- Node JS not serving the static image
- How to serve an image using nodejs
clone git repo:
git clone https://github.com/rsp/node-express-static-example.git
or download the ZIP file:
wget https://github.com/rsp/node-express-static-example/archive/master.zip
Inside the project directory run:
npm i
to install dependencies.
node app.js
For any bug reports or feature requests please post an issue on GitHub.
MIT License (Expat). See LICENSE.md for details.