Skip to content

Instantly share code, notes, and snippets.

@wilvk
Last active March 21, 2019 10:30
Show Gist options
  • Save wilvk/d0e147b45c875245acc12d1512201507 to your computer and use it in GitHub Desktop.
Save wilvk/d0e147b45c875245acc12d1512201507 to your computer and use it in GitHub Desktop.
example sync file api in node/express
var express = require('express');
var fs = require('fs');
var app = express();
var port = process.env.PORT || 8080;
app.get('/api', function(req, res) {
var contents = fs.readFileSync('DATA.txt', 'utf8');
res.send("test info: " + contents);
});
app.listen(port);
console.log('Server started! At http://localhost:' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment