Skip to content

Instantly share code, notes, and snippets.

@kuboon
Last active January 14, 2021 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuboon/72c09825058d29865e3a1aa6da0476e2 to your computer and use it in GitHub Desktop.
Save kuboon/72c09825058d29865e3a1aa6da0476e2 to your computer and use it in GitHub Desktop.
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