Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tkfm-yamaguchi/140a8453d71fc516eba50eaea8bb27cb to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/140a8453d71fc516eba50eaea8bb27cb to your computer and use it in GitHub Desktop.
Launch webrick as non-blocking http server
require 'webrick'
require 'open3'
server = WEBrick::HTTPServer.new(:DocumentRoot => './', Port: 9999, ServerType: Thread)
server.start
sleep 3
result = Open3.capture2e('curl http://localhost:9999/index.html')
p result
server.shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment