Skip to content

Instantly share code, notes, and snippets.

@adamcjoiner
Created October 30, 2019 14:12
Show Gist options
  • Select an option

  • Save adamcjoiner/9f61253406311995016ff452e23b1a4a to your computer and use it in GitHub Desktop.

Select an option

Save adamcjoiner/9f61253406311995016ff452e23b1a4a to your computer and use it in GitHub Desktop.
REST endpoint with HTML response (Node.js+Express.js)
var express = require('express');
var app = express();
var port = 3010;
var title = 'Homepage';
var home = '<h1>'+title+'</h1>';
app.get('/', function (req, res) {
console.log('GET / 300');
res.set('Content-Type', 'text/html');
res.send(home);
});
app.listen(port, function() {
console.log('Listening on port '+port+'...');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment