summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2014-02-06 16:50:27 +0100
committermh <mh@immerda.ch>2014-02-06 16:50:27 +0100
commit5cc2311b8dbaf882d390ae07e1ae6fe206833dd9 (patch)
treedafa622b47cc76c4b77bd8495f7002d20634aa24
first commitHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--Gemfile4
-rw-r--r--app.rb19
-rw-r--r--config.ru3
4 files changed, 27 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..63f1fef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.lock
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..758853d
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+gem 'sinatra'
+gem 'json_pure'
diff --git a/app.rb b/app.rb
new file mode 100644
index 0000000..958f4b9
--- /dev/null
+++ b/app.rb
@@ -0,0 +1,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
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000..ef0f920
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,3 @@
+require File.expand_path '../app.rb', __FILE__
+
+run Sinatra::Application