diff --git a/server.js b/server.js index 6de56e1..42c3200 100644 --- a/server.js +++ b/server.js @@ -2,11 +2,14 @@ var fs = require('fs'); var express = require('express'); var app = express(); +var bodyParser = require('body-parser'); +var serveStatic = require('serve-static'); var comments = [{author: 'Pete Hunt', text: 'Hey there!'}]; -app.use('/', express.static(__dirname)); -app.use(express.bodyParser()); +app.use('/', serveStatic(__dirname)); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded()) app.get('/comments.json', function(req, res) { res.setHeader('Content-Type', 'application/json'); @@ -19,4 +22,4 @@ app.post('/comments.json', function(req, res) { res.send(JSON.stringify(comments)); }); -app.listen(3000); \ No newline at end of file +app.listen(3000);