Skip to content

Instantly share code, notes, and snippets.

@victusfate
Forked from mislav/config.ru
Created October 16, 2011 18:41
Show Gist options
  • Save victusfate/1291253 to your computer and use it in GitHub Desktop.
Save victusfate/1291253 to your computer and use it in GitHub Desktop.
Shortest simplest sweetest web "hello {NAME}" in Ruby

This is the shortest "hello {NAME}" Ruby program I could make. It fits in a tweet!

  1. Save it as "config.ru"
  2. gem install rack
  3. Run rackup
  4. Visit http://localhost:9292/?name=NAME
run ->(e){ p=Hash[*e['QUERY_STRING'].split(/[&=]/)]; [200, {'Content-type'=>'text/html'}, ["Hello #{p['name']}!"]] }
# Of course, the same thing in Sinatra is way shorter! But I went for minimum dependencies above.
require 'sinatra'; get('/') { "Hello #{params[:name]}!" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment