Skip to content

Instantly share code, notes, and snippets.

@iwilsonq
Created March 1, 2017 07:21
Show Gist options
  • Save iwilsonq/27f58256b11a332e6ca90b0ce35371a5 to your computer and use it in GitHub Desktop.
Save iwilsonq/27f58256b11a332e6ca90b0ce35371a5 to your computer and use it in GitHub Desktop.
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'));
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