Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Created May 10, 2013 14:34
Show Gist options
  • Save tbuehlmann/5554778 to your computer and use it in GitHub Desktop.
Save tbuehlmann/5554778 to your computer and use it in GitHub Desktop.
class Application < Sinatra::Base
configure do
enable :static
set :views, File.join(File.dirname(__FILE__), 'views')
end
get '/' do
slim :index
end
get '/status', :provides => :json do
color = rand(2).even? ? 'red' : 'green'
{color: color}.to_json
end
end
h1 Hello World!
javascript:
$(document).ready(function() {
$("#foo").click(function() {
$.get('/status', function(data) {
$("#bar").attr("style", "color: " + data.color);
});
});
});
button type="button" id="foo" Update
.status#bar style="color: black" foo bar baz
doctype 5
html xmlns='http://www.w3.org/1999/xhtml'
head
title Application
link rel='stylesheet' type='text/css' href='/css/style.css'
meta content='text/html; charset=utf-8' http-equiv='Content-Type'
script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"
body
== yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment