Last active
October 19, 2017 18:04
-
-
Save antishok/d20bd4c6fd87e31298625bc6b98890e9 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
<html> | |
... | |
<script> | |
fetch('/ping') | |
.then((response) => response.json()) | |
.then((data) => { | |
console.log('pong', data); | |
}); | |
</script> | |
</html> |
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
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