Skip to content

Instantly share code, notes, and snippets.

@helen-dikareva
Created August 1, 2019 14:10
Show Gist options
  • Save helen-dikareva/8d4f40e902f4e915ecf3591c1f91d946 to your computer and use it in GitHub Desktop.
Save helen-dikareva/8d4f40e902f4e915ecf3591c1f91d946 to your computer and use it in GitHub Desktop.
var express = require('express');
var fs = require('fs');
var app = express();
app.get('/page', function (req, res) {
res.setHeader('content-type', 'text/html');
res.send(fs.readFileSync('./index.html'));
});
app.get('/', function (req, res) {
res.setHeader('content-type', 'application/json');
res.send(fs.readFileSync('./user.json'));
});
app.listen(3000, function () {
console.log('open http://localhost:3000/page');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment