Created
December 14, 2013 12:14
-
-
Save cuipengfei/7958522 to your computer and use it in GitHub Desktop.
express work json me
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 fs = require('fs') | |
var app = express() | |
app.get('/books', function (req, res) { | |
fs.readFile(process.argv[3], function (err, data) { | |
var jsonFromFile = JSON.parse(data.toString()); | |
res.json(jsonFromFile) | |
}) | |
}) | |
app.listen(process.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment