swank
python -m SimpleHTTPServer
for Javascript, with a few extras.
It's If you want to test local static files (HTML, JS, CSS), simply run swank
.
It's even got livereload and introspected tunnels built in.
Install
npm install -g swank
Usage
swank [[--ngrok | -n]] [[--watch | -w]] [[--silent | -s]] [[--interval | -i SECONDS]] [[--port | -p PORT]] [[ [[--path | -d]] root_directory]]
--ngrok
: pipe your server through ngrok's local tunnel--watch
: a watch+livereload server. Includeslivereload.js
in HTML files, starts the livereload server, and watches your directory, causing a reload when files change--interval
: how often watch polls for changes. Defaults to 1 second--silent
: disable logging of requests--port
: specify the local port to use. Defaults to$PORT
or8000
--path
: the path to the root directory of the server. Defaults to the current working directory
As a module
var defaults = path: '.' // the directory to use as root port: processenvPORT || 8000 // the port to serve on help: false // print help and exit ngrok: false // tunnel requests through ngrok. Set to an object to pass options to ngrok watch: false // run a liveReload server, and inject reload script into html pages. Can be an object with child object 'opts' for options to be passed to connect-livereload interval: 1000 // how often the watch system polls for file changes log: format: 'combined' opts: {} // enable loging of requests and errors. Format and opts are passed to morgan. set to false to silence output; defaults; //returns a promise
For example, if you want to use it with gulp
:
var gulp = ;var swank = ; gulp;
As middleware
var express = ;var Swank = Swank;var http = ; var app = ; app; var middleware = log: false watch: true;app; var server = http; middleware; //required for watch or ngrok functionality server; // will automatically start/stop watch or ngrok servers as required