Last active
September 15, 2020 20:37
-
-
Save rainchen/3a91ef481e78ad38d51c91da0ab40e7f to your computer and use it in GitHub Desktop.
a ruby implement of webify(https://github.com/beefsack/webify)
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 characters
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