Skip to content
Lloyd Brookes edited this page Jul 6, 2021 · 17 revisions

Please see the lws API docs. The local-web-server programmatic API is identical to lws with two differences:

  1. local-web-server has a default middleware stack while lws does not.
  2. local-web-server adds itself to the plugin module search path, meaning when you type --stack lws-static it will first search the current working directory then the local-web-server installation for the lws-static module.

Trival example:

import LocalWebServer from 'local-web-server'
const ws = await LocalWebServer.create({
  port: 9000,
  directory: 'public'
})

/* make requests */
// curl http://localhost:9000

/* shut down */
ws.server.close()
Clone this wiki locally