Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 14, 2013 12:14
Show Gist options
  • Save cuipengfei/7958522 to your computer and use it in GitHub Desktop.
Save cuipengfei/7958522 to your computer and use it in GitHub Desktop.
express work json me
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