Created
March 1, 2017 07:21
-
-
Save iwilsonq/27f58256b11a332e6ca90b0ce35371a5 to your computer and use it in GitHub Desktop.
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
const express = require('express'); | |
const app = express(); | |
app.get('/', function(req, res) { | |
res.send({hi: 'there'}); | |
}); | |
app.listen(1337, console.log('Server listening on http://localhost:1337')); |
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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
const store = []; | |
app.get('/', function(req, res) { | |
res.send({hi: 'there'}); | |
}); | |
app.get('/articles', function(req, res) { | |
res.send(store); | |
}); | |
app.post('/articles', function(req, res) { | |
store.push(req.body.content); | |
res.send('Article added!'); | |
}); | |
app.listen(1337, console.log('Server listening on http://localhost:1337')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment