Created
February 7, 2012 22:28
Revisions
-
bheeshmar revised this gist
Feb 8, 2012 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,16 @@ require 'webrick' require 'tempfile' # Start gvim in foreground mode $EDITOR = "gvim -f " s = WEBrick::HTTPServer.new(:Port => 9292) %w(INT TERM).each { |signal| trap(signal) { s.shutdown } } s.mount_proc("/") do |req,res| t = Tempfile.open('textaid') { |f| f.write(req.body); f } system($EDITOR + t.path) res.body = File.read(t.path) t.unlink end s.start -
bheeshmar revised this gist
Feb 8, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ require 'webrick' # Start gvim in foreground mode $EDITOR = "gvim -f" s = WEBrick::HTTPServer.new(:Port => 9292) trap("INT") { s.shutdown } -
bheeshmar revised this gist
Feb 8, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # Start gvim in foreground mode $EDITOR = "gvim --no-fork" s = WEBrick::HTTPServer.new(:Port => 9292) trap("INT") { s.shutdown } s.mount_proc("/") do |req,res| -
bheeshmar revised this gist
Feb 8, 2012 . 1 changed file with 7 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,32 +1,14 @@ require 'webrick' # Start gvim in foreground mode $EDITOR = "gvim --no-fork" 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 -
bheeshmar created this gist
Feb 7, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ require 'webrick' include WEBrick # Start gvim in foreground mode $EDITOR = "gvim -f" class FileUploadServlet < HTTPServlet::AbstractServlet def do_POST(req, res) filedata = req.body # TODO: Use tempfile instead of foo.out. File.open("foo.out", "wb") do |f| f.syswrite(filedata) end system($EDITOR + " foo.out") res.body = File.read("foo.out") end end s = HTTPServer.new( :Port => 9292, #:Logger => Log.new(nil, BasicLog::WARN), :AccessLog => [], :DocumentRoot => Dir.pwd) s.mount("/", FileUploadServlet) trap("INT") { s.shutdown } puts 'Starting' s.start puts 'Bye'