stattic

0.4.0 • Public • Published

stattic

npm npm Dependency Status npm

Ridiculous simple script for serving static files using http module.

Installation

Install it using NPM:

npm install stattic --save

Usage

Example of a very simple server that shows all the static files on the public folder:

//Import stattic
let stattic = require("stattic");
 
//Run the web server
stattic({
    "folder": "./public",
    "port": 5000
});

API

stattic(options)

Starts a new server with the configuration specified in the options object. The following table lists the available options:

key Description Type Default value
folder Sets the path of your static files folder. String ./
port Sets the port of your server. Integer 5000
cors Enable cross-origin resource sharing (CORS). Boolean false
index Sets the index file name. String index.html

CLI usage

You can install the CLI by running the following command:

npm install -g stattic

Now you can navigate to a folder with your static files and initialize a static server:

cd /path/to/your/static/content/
stattic --port 5000 --cors

This will start a new static server in the port 5000 that will serve all files placed in the current folder.

CLI options

--port PORT

Specify the port for your static server. Default is 5000.

--folder FOLDER

You can specify a different folder to serve the static files. Example

stattic --port 5000 --folder /path/to/your/static/content/

--cors

Use this option to enable cors.

License

MIT LICENSE © Josemi Juanes.

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i stattic

    Weekly Downloads

    46

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    8.35 kB

    Total Files

    5

    Last publish

    Collaborators

    • jmjuanes