Skip to content

Instantly share code, notes, and snippets.

@raggi

raggi/config.ru Secret

Created July 13, 2014 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raggi/5ce37897f5f1321aaddb to your computer and use it in GitHub Desktop.
Save raggi/5ce37897f5f1321aaddb to your computer and use it in GitHub Desktop.
class App
HTML = <<-HTML
<!doctype html>
<html><head><title>issue 599</title></head>
<body>
<script defer>
setInterval(function() {
var xhr = new XMLHttpRequest()
xhr.open("GET", "/work")
xhr.send()
}, 1000);
</script>
</body>
</html>
HTML
def call(env)
case Rack::Request.new(env).path
when "/"
Rack::Response.new([HTML]).finish
when "/work"
res = Rack::Response.new
res.set_cookie("work", Time.now.to_s)
res.finish
else
Rack::Response.new([], 404).finish
end
end
end
run App.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment