Socket
Socket
Sign inDemoInstall

lite-webserver

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lite-webserver

creates simple web server.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

lite-webserver

The npm package to create simple web server.

This will load files from /public directory if it's not specified.

Install

npm i lite-webserver

Example

This server will load files from /public directory.

var { WebServer } = require("lite-webserver")
var server = new WebServer()

server.start()

If you want to specify the directory to load a file, use the code below.

var { WebServer } = require("lite-webserver")
var server = new WebServer({
  dir: "./public_html"
})

server.start()

API

WebServer(options)

Constructor

options
port (optional)

Type: Number

Default: 3000

new WebServer({
  port: 3000
})
directory (optional)

Type: String

Default: ./public

The directory to load the file.

new WebServer({
  dir: "./public_html"
})
notfound (optional)

Type: String (html code)

Default: 404 Not Found

new WebServer({
  notfound: "File was not found on this server."
})

GetContentType(name)

Function

name

Type: String

Type a filename to get http header content-type.

var { GetContentType } = require("lite-webserver")

var htmlname = "example.html"
var contenttype = GetContentType(htmlname)
console.log(contenttype) // "text/html"

var pngname = "image.png"
var contenttype = GetContentType(pngname)
console.log(contenttype) // "image/png"

License

© chasyumen 2021. Released under the MIT license

Keywords

FAQs

Last updated on 29 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc