From the course: Express Essentials: Build Powerful Web Apps with Node.js

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Serving static files with Express

Serving static files with Express

- [Instructor] In addition to using Express to query and fetch data from APIs, you can also use express to serve static files. Static files, in this case, are files that are not going to change. So typically you might serve files like photos, PDFs, document files, but you can also serve more development specific files like HTML and CSS files. If you take a look at the exercise files for this course, you should see a folder labeled static_files. In this folder, there are two images: mountains_1 and mountains_2. We are going to serve up these photos, which are examples of static files using our Express project. I'm going to show you two different ways to accomplish this. Let's go ahead and get started in our VS Code. The first thing that we're going to do is create a new folder at the root of our project called public. You can create your folder in a few ways. If you want to use the command line to do so, please feel…

Contents