The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Static site development

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andrew Montgomery

Posts: 42
Nickname: darkliquid
Registered: Sep, 2006

Andrew Montgomery is a lead developer for UK-based web development company SonicIQ
Static site development Posted: Nov 24, 2006 4:03 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Andrew Montgomery.
Original Post: Static site development
Feed Title: Dark Liquid - Ruby
Feed URL: http://feeds.feedburner.com/DarkLiquid-Ruby
Feed Description: Ruby and Rails related ramblings by Andrew Montgomery
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Andrew Montgomery
Latest Posts From Dark Liquid - Ruby

Advertisement

When developing a static site, or editing an existing one, its a bitch to try and remember things like relative and absolute paths, etc etc. I didn���t want to have to mess with that and I certainly didn���t want the hassle of setting up apache or lighty just to serve files from the directory I had mirrored the site.

So, Ruby to the rescue! 2 minutes later and I had this serving my files for me:

#!/usr/local/bin/ruby
require 'webrick'
include WEBrick

def webserve(port, directory)
  server = HTTPServer.new(
    :Port            => port,
    :DocumentRoot    => directory
  )
  trap("INT"){ server.shutdown }
  server.start
end

port = ARGV[0] || 3000
directory = ARGV[1] || Dir::pwd
webserve(port, directory)

Just run it in the directory that has your files in, or call it like:

webserver 3000 /path/to/my/files

and voila, instant server.

I don���t know how people live without this stuff.

Read: Static site development

Topic: Maintaining database column order with migrations Previous Topic   Next Topic Topic: CSS and JS directories in Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use