Skip to content

Instantly share code, notes, and snippets.

@dongelen
Created November 19, 2018 15:35
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 dongelen/b3b4675c6215ce0bafbd967c353a6817 to your computer and use it in GitHub Desktop.
Save dongelen/b3b4675c6215ce0bafbd967c353a6817 to your computer and use it in GitHub Desktop.
<!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>
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