Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including static-cling with all npm packages installed. Try it out:

var staticCling = require("static-cling")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

static-cling v1.0.1

Static file server

#Static Cling This is a node.js module that allows you to spin up a static file server either from code or from the command line.

###Installing $ npm install static-cling

Don't forget to use the global flag (--g) if you want the command line option everywhere.

###At the command line $ static

Yeah, that's it. You have the option to pass in -p for port, otherwise it defaults to port 3000, -d for directory, if you want to specify a different directory than the one you are in, and lastly -f for the default html page, this defaults to index.html

###In Code Static Cling is available to be used as a module as well if you want to use node to host static files.

require('static-cling').cling();

Options

If using the module you can override the defaults by providing a config object

//defaults
var config = {
    root: '.',
    port: 3000,
    filename: 'index.html'
}
//overriding defaults
cling({ port: 3456, root : './other/', filename: 'test.html' });

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free