Skip to content

Instantly share code, notes, and snippets.

@kuboon
Last active Jan 14, 2021
Embed
What would you like to do?
require 'webrick'
require 'cgi'
s = WEBrick::HTTPServer.new(
:Port => 8000,
:HTTPVersion => WEBrick::HTTPVersion.new('1.1'),
:AccessLog => [[open(IO::NULL, 'w'), '']] # アクセスログを出力しない
)
s.mount_proc('/') do |req, res|
body = File.read('episopass.html')
res.status = 200
res['Content-Type'] = 'text/html'
res.body = body
end
s.mount_proc('/receive') do |req, res|
puts req.body # 標準出力へ返す、もしくは処理を継続
s.shutdown
end
Signal.trap('INT'){s.shutdown}
s.start
puts 'open http://localhost:8000'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment