Class

WebServer

WebServer(optionsopt) → {WebServer}

Create a WebServer.

Constructor

# new WebServer(optionsopt) → {WebServer}

Parameters:
Name Type Attributes Description
options WebServerOptions <optional>

WebServer Options.

View Source WebServer.js, line 63

WebServer
Examples

Simple example

const { WebServer } = require("lite-web-server");
var server = new WebServer();

server.start();

Options Example

const { WebServer } = require("lite-web-server");
var server = new WebServer({
  port: 3000, //port
  directory: "./public", //directory to publish
  serveindex: false, //disable serve-Index feature.
  acceptonlyget: true, //returns 405 to the request with method other than GET.
  useindexhtml: true, //returns /index.html on that directory when the directory was requested.
  rootfile: "/index.html", //the file that is used as the home page.
  errordocument: {
    _404: `./public/404.html`, //File path to use as a 404 error page.
    _405: `./public/405.html`, //File path to use as a 405 error page.
  }
});

Methods

# start() → {Promise.<(Object|null)>}

View Source WebServer.js, line 95

Promise.<(Object|null)>