Skip to content

Instantly share code, notes, and snippets.

@antishok
Last active October 19, 2017 18:04
Show Gist options
  • Save antishok/d20bd4c6fd87e31298625bc6b98890e9 to your computer and use it in GitHub Desktop.
Save antishok/d20bd4c6fd87e31298625bc6b98890e9 to your computer and use it in GitHub Desktop.
<html>
...
<script>
fetch('/ping')
.then((response) => response.json())
.then((data) => {
console.log('pong', data);
});
</script>
</html>
const path = require('path');
const express = require('express');
const tcpp = require('tcp-ping');
const app = express();
app.use('/', express.static(path.join(__dirname, 'public')));
app.get('/ping', (request, response) => {
tcpp.ping({ address: '46.28.246.123' }, function(err, data) {
response.json( data );
});
});
app.listen(3000, () => {
console.log('listening on port 3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment