Created
May 10, 2013 14:34
-
-
Save tbuehlmann/5554778 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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