We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Fileservers

A fileserver is a kind of simple web server that serves static files from the host machine. Fileservers are often used to serve static assets for a website, things like:

  • HTML
  • CSS
  • JavaScript
  • Images

Assignment

Node.js with the express library makes it very easy to make a fileserver. Build and run a fileserver that serves a file called index.html from its root at http://localhost:8080. That file should contain this HTML:

<html>
  <body>
    <h1>Welcome to Chirpy</h1>
  </body>
</html>

Steps

We'll cover what middleware is in a later lesson

import express from "express";

const app = express();
const PORT = 8080;

app.use(express.static("."));

app.listen(PORT, () => {
  console.log(`Server is running at http://localhost:${PORT}`);
});

Run and submit the CLI tests.