Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created May 10, 2011 20:25
Show Gist options
  • Save ryanbriones/965313 to your computer and use it in GitHub Desktop.
Save ryanbriones/965313 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# From: https://github.com/ryanbriones/cgiup/blob/master/bin/cgiup
require 'webrick'
unless ARGV[0]
STDERR.puts "usage: cgiup [PATH TO CGI SCRIPT]"
exit 1
end
cgi_script = File.expand_path(ARGV[0])
unless File.exists?(cgi_script)
STDERR.puts "CGI Script: #{cgi_script} Not Found"
exit 1
end
server = WEBrick::HTTPServer.new(:Port => 2000)
server.mount('/', WEBrick::HTTPServlet::CGIHandler, File.expand_path(ARGV[0]))
trap("INT"){ server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment