Created
December 13, 2015 19:45
-
-
Save cmstead/1cb72799dfd5505eb484 to your computer and use it in GitHub Desktop.
Express serving static files from a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Serving static files in a named directory, served from the root path | |
| app.use(express.static('path/to/static/files')); // This will pick up deep references within named directory | |
| // http://localhost:3000/js/foo.js <- foo.js lives in path/to/static/files/js/foo.js | |
| // Serving files from a virtual directory | |
| app.use('/blar', express.static('path/to/static/files')); | |
| // http://localhost:3000/blar/js/foo.js <- foo.js lives in path/to/static/files/js/foo.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment