Giter Site home page Giter Site logo

jmjuanes / stattic Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 38 KB

Ridiculous simple script for serving static files.

Home Page: https://www.npmjs.com/package/stattic

License: MIT License

JavaScript 100.00%
static-site static-server nodejs-server static static-files

stattic's Introduction

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.

stattic's People

Contributors

jmjuanes avatar

Watchers

 avatar  avatar  avatar

stattic's Issues

Security issue

Hi,

I'm a member of the Node.js Security WG and we received a report regarding a security issue with this module.

We tried inviting the author by e-mail but received no response so I'm opening this issue and inviting anyone with commit and npm publish rights to collaborate with us on a fix.

Fix static files path

> [email protected] test /Users/jmjuanes/git/coverviewer-dev
> node dev.js


Welcome to Stattic
Visit us: http://statticjs.github.io

Static server listening on: http://localhost:5001
Static files listening from: /Users/jmjuanes/git/coverviewer-dev/node_modules/coverviewer-build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.