1.0.1 • Published 7 years ago

serve-local v1.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

Serve local

Minimalistic local server for static content. Creates an instance of Node HTTP Server.

Install

npm i -D serve-local

Setup

Server factory requires 2 parameters - documentRoot and port.

/* Requiring the package. */
const serveLocal = require('serve-local');

/* Arguments */
const documentRoot = 'C:';
const port = '8080';

/* Creating instance. */
const server = serveLocal(documentRoot, port);
require('serve-local')('C:', 8080);

Usage

Server is an instance of Node HTTP Server. It exposes all the events, properties and methods.

/* Close the server. */
server.close(() => console.log('closed'));

/* Checking server status. */
console.log(`Is server listening: ${server.listening}`);