Last active
January 14, 2021 02:23
-
-
Save kuboon/72c09825058d29865e3a1aa6da0476e2 to your computer and use it in GitHub Desktop.
This file contains 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 '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