Skip to content

Instantly share code, notes, and snippets.

@reu
Created December 8, 2014 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reu/fb29f2c4f79bb1df6892 to your computer and use it in GitHub Desktop.
Save reu/fb29f2c4f79bb1df6892 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
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, cgi_script)
trap("INT"){ server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment