Question
What does static('public')
do?
Answer
The static method of express allows us to serve all the static files of our application, that is to say, all HTML, CSS, and JS files that will comprise the front end visuals on the browser. In our case:
express.static('public');
Public is the name of the directory where we find those files, for example, in our execise:

We can see that public contains a CSS and a JS directory, as well as an index.html and the expressions.js file.
By placing the express.static() in app.use, we let our server know that we will be rendering that index.html file and implementing all those static CSS and JS files related to it.
app.use(express.static('public'));
That is the purpose of the static()
method.
8 Likes
Does anyone else have line app.use(express.static('public'));
used twice in their lesson? If so, why?
I thought it’s something I ‘injected’ by mistake, but it’s still there after I reset the exercise.
I deleted the second iteration, restarted the server and the app still works fine. Bug? 
const express = require('express');
const app = express();
// Serves Express Yourself website
app.use(express.static('public')); <----------------- One
const { getElementById, getIndexById, updateElement,
seedElements, createElement } = require('./utils');
const expressions = [];
seedElements(expressions, 'expressions');
const PORT = process.env.PORT || 4001;
// Use static server to serve the Express Yourself Website
app.use(express.static('public')); <----------------- Two
1 Like
Not a bug, but a repeated line of code. You can easily comment or delete one of both and the script will still work.
Hi! Does anyone know what the jquery-3.2.1.min.js file here is used for? Thanks 
1 Like
Hi. It’s a relatively simple (and old) JavaScript library that is used to speed up JS app development (compared to clean JS). Its official site https://jquery.com/
You can safely ignore it (in the context of the Node.js Express lesson).