Skip to content

Instantly share code, notes, and snippets.

@rainchen
Last active September 15, 2020 20:37
Show Gist options
  • Save rainchen/3a91ef481e78ad38d51c91da0ab40e7f to your computer and use it in GitHub Desktop.
Save rainchen/3a91ef481e78ad38d51c91da0ab40e7f to your computer and use it in GitHub Desktop.
a ruby implement of webify(https://github.com/beefsack/webify)
require 'webrick'
require 'open3'
server = WEBrick::HTTPServer.new :Port => 8000
server.mount_proc('/') { |req, res| res.body = Open3.capture2(ARGV[0], :stdin_data=>req.body)[0] }
trap('INT') { server.shutdown }
server.start
# server:
# ruby webify-webrick.rb "wc -c"
# client:
# curl -d 'This is a really long sentence' http://localhost:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment