Title

Global

Methods

# GetFileType(Filename) → {string}

Get content type of the file name for http header.

Parameters:
Name Type Description
Filename string

Filename to get header content type.

View Source GetFileType/index.js, line 15

Filetype

string
Example
const { GetFileType } = require("lite-web-server")
var filetype = GetFileType("main.js")

Type Definitions

object

# WebServerOptions

WebServer's options.

Properties:
Name Type Attributes Default Description
options object <optional>
port Number <optional>
3000

Port to host the page.

directory string <optional>
./public/

The directory to load the file.

serveindex boolean <optional>
false

If it's true, return the file list of the directory when the directory was requested. (If index.html exists in the directory, it will be sent preferentially)

acceptonlyget boolean <optional>
true

Only accepts get request.

useindexhtml boolean <optional>
true

If it's true, returns ./index.html file when requested directory.

rootfile string <optional>
/index.html

You can specify a file to load as a top page. (Please specify files in the published directory.)

errordocument object <optional>
errordocument._404 string <optional>
`${__dirname}/assets/def_pages/404.html`

Html file path to respond on the request methods other than GET.

errordocument._405 string <optional>
`${__dirname}/assets/def_pages/405.html`

Html file path to respond on not found.

View Source WebServer.js, line 7

Example

All 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.
  }
});