Displaying static files in Express

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

If you want the webapp in the last tutorial to display a static image, it would give a 404 error.  To fix this, use the express.static middleware like this …

display static files in Express

That means that anything placed inside the “public” folder will be display straight through by Express without processing.  Note that there is no “public” in the URL.

You can learn more here.