Skip to content

Instantly share code, notes, and snippets.

@junsuk5
Created April 6, 2017 12:18
Show Gist options
  • Select an option

  • Save junsuk5/c9928404417b59a9dded1a74c3baa35c to your computer and use it in GitHub Desktop.

Select an option

Save junsuk5/c9928404417b59a9dded1a74c3baa35c to your computer and use it in GitHub Desktop.
Node express sample
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World')
})
app.get('/user/:id', function (req, res) {
res.send('GET ' + req.params.id);
});
app.post('/user', function (req, res) {
res.json({
success: true
});
});
app.put('/user', function (req, res) {
res.status(400).json(
{
message: 'Bad Request'
}
)
})
app.delete('/user', function (req, res) {
res.send('DELETE');
})
app.listen(3000, function () {
console.log('Server Started');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment