Created
October 30, 2019 14:12
-
-
Save adamcjoiner/9f61253406311995016ff452e23b1a4a to your computer and use it in GitHub Desktop.
REST endpoint with HTML response (Node.js+Express.js)
This file contains hidden or 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
| 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