Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Last active October 10, 2017 12:59
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 allthingsclowd/c2781a67388be4ee89a3e026df38f330 to your computer and use it in GitHub Desktop.
Save allthingsclowd/c2781a67388be4ee89a3e026df38f330 to your computer and use it in GitHub Desktop.
Really simple NodeJS Webserver that returns an image the the servers hostname - used for autoscaling demo
const express = require('express')
const app = express()
const serverName = require('os').hostname();
const messageTop = '<div class="middle">\
<img src="https://www.fujitsu.com/uk/Images/K5-climber-580x224_tcm23-2619235.jpg" alt="K5 Autoscale">\
<h1>Hello from '
const messageTail = '</h1>\
<hr>\
</div>\
</div>'
app.get('/', function (req, res) {
res.send(messageTop + serverName + messageTail)
})
app.listen(80, function () {
console.log('Example app listening on port 80')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment