summaryrefslogtreecommitdiffstats
path: root/app.rb
blob: 958f4b9f8cc34bbaf6d7561888a06a1dd781fc17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'rubygems'
require 'sinatra'
require 'json/pure'
get '/' do
  res = "<html><body style=\"margin:0px auto; width:80%; font-family:monospace\">"
  res << "<head><title>Environment</title><meta name=\"viewport\" content=\"width=device-width\"></head>"
  res << "<h2>Environment</h2>"
  res << "<div><table>"
  ENV.keys.sort.each do |key|
    res << "<tr><td><strong>#{key}</strong></td><td>#{ENV[key]}</tr>"
  end
  res << "</table></div>"
  res << "<h2>HTTP Request Headers</h2>"
  res << "<div><table>"
  env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}.sort.each do |k,v|
    res << "<tr><td><strong>#{k}</strong></td><td>#{v}</tr>"
  end
  res << "</table></div></body></html>"
end