Skip to content

Instantly share code, notes, and snippets.

@bheeshmar
Created February 7, 2012 22:28
Show Gist options
  • Save bheeshmar/1762576 to your computer and use it in GitHub Desktop.
Save bheeshmar/1762576 to your computer and use it in GitHub Desktop.
Webserver for Textaid Chrome plugin
require 'webrick'
# Start gvim in foreground mode
$EDITOR = "gvim -f"
s = WEBrick::HTTPServer.new(:Port => 9292)
trap("INT") { s.shutdown }
s.mount_proc("/") do |req,res|
File.open("textaid.txt", "wb") { |f| f.syswrite(req.body) }
system($EDITOR + " textaid.txt")
res.body = File.read("textaid.txt")
end
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment