0.4.0 • Published 6 years ago
stattic v0.4.0
stattic
Ridiculous simple script for serving static files using http module.
Installation
Install it using NPM:
npm install stattic --saveUsage
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 statticNow you can navigate to a folder with your static files and initialize a static server:
cd /path/to/your/static/content/
stattic --port 5000 --corsThis 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.