Skip to content

Instantly share code, notes, and snippets.

@wjlroe
Created August 13, 2012 10:20
Show Gist options
  • Save wjlroe/3339169 to your computer and use it in GitHub Desktop.
Save wjlroe/3339169 to your computer and use it in GitHub Desktop.
How to serve static files with POW

Problem

You wanna serve up static files, but are bored by the usual trick of:

python -m SimpleHTTPServer

This is pretty simple but why type this every time? Let's use Pow for some zero-effort web serving. If you have Pow already set up, then just drop the provided config.ru file into the root of your static files. Then link your directory into ~/.pow so Pow can see it and that's it!

Let's say you have a directory with mockups you wanna show people, they are in ~/Dropbox/Mockups/ then you might do this:

cd ~/Dropbox/Mockups/fancy_new_design/
wget https://raw.github.com/gist/3339169/7ae9f9e8eb1b6cd91fbf651641fa823c25622174/config.ru
cd ~/.pow
ln -s ~/Dropbox/Mockups/fancy_new_design .

Then you can marvel at your creation

Have fun!

#!/usr/bin/env ruby
map "/" do
use Rack::Static,
:urls => [""], :root => File.expand_path('.'), :index => 'index.html'
run lambda {|*|}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment