Last active
March 21, 2019 10:30
-
-
Save wilvk/d0e147b45c875245acc12d1512201507 to your computer and use it in GitHub Desktop.
example sync file api in node/express
This file contains 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 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