Created
June 28, 2011 20:51
-
-
Save luke-gru/1052173 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
#!/usr/bin/env ruby | |
require 'webrick' | |
include WEBrick | |
s = HTTPServer.new(:Port => 2002) | |
class MyServlet < HTTPServlet::AbstractServlet | |
def do_GET(req, res) | |
filecontents = File.open(ENV['HOME'] + "/.hubeyerc", "r") {|f| f.read} | |
res['Content-type'] = "text/html" | |
res.body = %{ | |
<html><body> | |
<p>Hello. You're calling from a #{req['User-Agent']}</p> | |
<p>I see parameters: #{req.query.keys.join(', ')}</p> | |
<pre>#{filecontents}</pre> | |
</body></html> | |
} | |
end | |
end | |
s.mount("/cool", MyServlet) | |
trap("INT") { s.shutdown } | |
s.start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment