Skip to content

Instantly share code, notes, and snippets.

@mhayes
Created October 4, 2013 22:42
Show Gist options
  • Save mhayes/6834060 to your computer and use it in GitHub Desktop.
Save mhayes/6834060 to your computer and use it in GitHub Desktop.
Start a simple web server from the current directory by running `s` in terminal!

Quickstart

Setup

  1. Place s in /usr/local/bin/s
  2. Run chmod +x /usr/local/bin/s

Usage

Let's assume you have a static site setup in ~/Sites/awesomeapp. Open up terminal and run the following commands:

cd ~/Sites/awesomeapp
s

That's it!

#!/usr/bin/env node
var connect = require('connect'),
path = require('path'),
http = require('http'),
exec = require('child_process').exec,
DEFAULT_PORT = 8080;
var cwd = process.cwd();
var app = connect()
.use(connect.logger('dev'))
.use(connect.static(cwd));
http.createServer(app).listen(DEFAULT_PORT);
console.info('Server started at http://localhost:' + DEFAULT_PORT + '/')
exec("open http://localhost:" + DEFAULT_PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment