Skip to content

Instantly share code, notes, and snippets.

@ixti
Last active August 29, 2015 14:02
Show Gist options
  • Save ixti/ec192b521b6478e59601 to your computer and use it in GitHub Desktop.
Save ixti/ec192b521b6478e59601 to your computer and use it in GitHub Desktop.
Tiny echo-server I use to investigate OAuth callback responses :D
require "erb"
begin
require "awesome_print"
rescue LoadError
puts "Install Awesome Print first:"
puts
puts " gem install awesome_print"
puts
exit 1
end
TEMPLATE = ERB.new <<HTML
<!doctype html>
<head><meta charset="utf-8" /></head>
<body>
<h1>ENV</h1>
<%= env.ai :html => true %>
<h1>QUERY</h1>
<%= Rack::Request.new(env).params.ai :html => true %>
</body>
</html>
HTML
HEADERS = { "Content-Type" => "text/html" }
run lambda { |env| [200, HEADERS, [TEMPLATE.result(binding)]] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment