To create a basic static file server in Node.js, we use Express.
For instance, we write
const express = require("express");
const app = express();
const port = process.env.PORT || 4000;
app.use(express.static(__dirname + "/public"));
app.listen(port);
to create a file server by calling express.static
to expose the /public folder as a static folder.
We call app.listen
to start a web server.