liveBook · Manning

Http-server module

As explained in Web Components in Action

A command-line Node.js package that serves files over HTTP from a local directory.

The http-server module is a command-line Node.js package for serving files from a local directory over HTTP. Install it globally with npm, navigate to a project folder, and run http-server to make HTML available in a browser. section 2.6

A minimal workflow is:

  • Install Node.js, then install the module globally with npm. section 2.6
  • Create a project directory and add a test.html file. section 2.6
  • Run http-server from the project directory and open the reported localhost address, adding /test.html. section 2.6

Serving a component demo

A folder containing an HTML page can be served with http-server, letting the browser load a custom photo-carousel element and its assets through HTTP rather than directly from the filesystem. section 2.6

npm install http-server -g

View the installation command used to make http-server available globally. section 2.6

How Web Components in Action covers it

How deep it goes
Explains installation, directory setup, server execution, and browser access, but does not examine HTTP-server internals.
Examples
Uses a test.html page and a photo-carousel demo served from a project directory.
What it assumes
Assumes command-line access and teaches Node.js and npm installation before introducing the server workflow.
What you can do after
Operate/configure a local HTTP server and verify browser-loaded HTML through a localhost URL.
How it connects
Connects Node.js, npm, HTTP, browsers, HTML, and Web Components.

Also explained in

Compare how 2 books explain http-server module →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.