Created
November 19, 2018 15:35
-
-
Save dongelen/b3b4675c6215ce0bafbd967c353a6817 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
<!DOCTYPE html> | |
<head> | |
<title>Hartslag</title> | |
<style> | |
div { | |
font-size: 90px; | |
} | |
</style> | |
<script src="https://js.pusher.com/4.3/pusher.min.js"></script> | |
<script> | |
// Enable pusher logging - don't include this in production | |
Pusher.logToConsole = true; | |
var pusher = new Pusher('', { // Your channel | |
cluster: 'eu', | |
forceTLS: true | |
}); | |
var channel = pusher.subscribe('my-channel'); | |
channel.bind('my-event', function(data) { | |
let element = document.getElementById("heartrate"); | |
element.innerHTML = data.message; | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Hartslag</h1> | |
<div id="heartrate" > | |
_ | |
</div> | |
</body> |
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
require 'sinatra' | |
require 'pusher' | |
pusher_client = Pusher::Client.new( | |
app_id: '', # Your app id and secrets... | |
key: '', | |
secret: '', | |
cluster: 'eu', | |
encrypted: true | |
) | |
get '/' do | |
erb :index | |
end | |
get '/heartrate/:rate' do | |
pusher_client.trigger('my-channel', 'my-event', { | |
message: params['rate'] | |
}) | |
'' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment